toonz Posted November 30, 2008 Share Posted November 30, 2008 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 Quote Link to comment Share on other sites More sharing options...
jscix Posted November 30, 2008 Share Posted November 30, 2008 SELECT DATE_FORMAT(CURDATE(), '%d/%m/%Y') Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 30, 2008 Share Posted November 30, 2008 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 Quote Link to comment Share on other sites More sharing options...
toonz Posted November 30, 2008 Author Share Posted November 30, 2008 so how/where do I insert it into the string {$ctoninfo.release_date} thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 30, 2008 Share Posted November 30, 2008 You don't. You do that in your mysql SELECT query that is retrieving the data from the database. Quote Link to comment Share on other sites More sharing options...
toonz Posted November 30, 2008 Author Share Posted November 30, 2008 ah, well since I have 0 experience coding php, I dont think I will be altering the php file. I have only been working on the ptl files to change layouts and formatting Quote Link to comment Share on other sites More sharing options...
toonz Posted November 30, 2008 Author Share Posted November 30, 2008 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 Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 30, 2008 Share Posted November 30, 2008 Are you using Smarty? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 30, 2008 Share Posted November 30, 2008 You would not change {$ctoninfo.release_date} in the template, you would change the existing code that queries the database and places the content into that variable. Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 30, 2008 Share Posted November 30, 2008 In smarty you could actually use date_format modifier. That's one of the ideas behind templates. Template designer does not have to (should not!) modify database code. Quote Link to comment Share on other sites More sharing options...
toonz Posted November 30, 2008 Author Share Posted November 30, 2008 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 Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 30, 2008 Share Posted November 30, 2008 {$ctoninfo.release_date|date_format:"%m-%d-%Y"} Quote Link to comment Share on other sites More sharing options...
toonz Posted November 30, 2008 Author Share Posted November 30, 2008 Mchl, youre brilliant! worked like a charm. thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.