Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

html_select_date

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
ski
Smarty n00b


Joined: 23 Feb 2005
Posts: 1

PostPosted: Wed Feb 23, 2005 4:49 pm    Post subject: html_select_date Reply with quote

I spent a while figuring out why my assigned time value was not getting selected in the html from html_select_date.

My data came out of the database as a straightforward DATE value "YYYY-MM-DD"
Code:
SELECT eventdate .....


//assign variables...
Code:
$smarty->assign('eventdate', $mysqlrow['eventdate']);


//Template code
Code:
<!--{html_select_date time=$eventdate}-->


This worked okay.

But as soon as you start getting fancy with the date format - in this instance I wanted to shorten the month to "Jan", "Feb", etc.

Code:
<!--{html_select_date time=$event.dt month_format="%b"}-->


You have to make sure that the format of $event.dt matches the format you specified

e.g. you need to format your date from a database as follows....
Code:

SELECT DATE_FORMAT(`date`, '%b %d %Y') AS event.dt ....


OR do the following:

//Create a TIMESTAMP using the YYYY-MM-DD values.

Code:
$time = strtotime($eventdate);
$smarty->assign('eventtime', $time);


Code:
<!--{html_select_date time=$eventtime month_format="%b"}-->

Rolling Eyes
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Feb 23, 2005 5:56 pm    Post subject: Reply with quote

The time attribute can accept UNIX timestamps (even negative ones), YYYY-MM-DD, MySQL timestamps or anything parsable by strtotime().
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP