|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ski Smarty n00b
Joined: 23 Feb 2005 Posts: 1
|
Posted: Wed Feb 23, 2005 4:49 pm Post subject: html_select_date |
|
|
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"}-->
|
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Feb 23, 2005 5:56 pm Post subject: |
|
|
The time attribute can accept UNIX timestamps (even negative ones), YYYY-MM-DD, MySQL timestamps or anything parsable by strtotime(). |
|
Back to top |
|
|
|
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
|