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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.