Jump to content

converting datetime format


toonz

Recommended Posts

I have added a line item on one of my .tpl pages to show the date. since it is pulling the datetime stamp from the db, it shows a date like 1226325111 right now. since the info is being pulled from

 

<td><B>{$ctoninfo.release_date}</B> </td>

 

how do I alter the code to only display the date formatted to 'mm-dd-yyyy'?

 

thanks in advance

Link to comment
Share on other sites

If your column in your database holds a Unix Timestamp, you can convert and format it using the mysql FROM_UNIXTIME(unix_timestamp,format) function in your query. Use the same format string that jscix gave in the DATE_FORMAT example.

 

Ref: http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_from-unixtime

Link to comment
Share on other sites

ok, say I add this line towards the top of the php file

 

$str_sql = "select DATE_FORMAT(FROM_UNIXTIME(release_date), '%m/%d/%Y')";

 

in the tpl file, I changed the target from

 

{$ctoninfo.release_date}

 

to

 

{$release_date}

 

now instead of pulling up a datetime string of numbers, it gives a blank space. how do I make it so that template knows to pull the newly converted timestamp from the php file?

 

thanks again

 

Link to comment
Share on other sites

yes, from the looks of the code there is smarty. I see a row like

 

$smarty->assign("toon_path",$tpth);

 

 

so how do have the tpl pull the newly formatted date into the actual template to display on the web page? thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.