Showing posts with label php smarty. Show all posts
Showing posts with label php smarty. Show all posts

Friday, November 16, 2007

Smarty format date

How to format date in Smarty



When you extract a date field from database, it is in the format yyyy-mm-dd. But maybe you want to list it other format, for example dd-mm-yyyy. You can retrieve this format directly from database, usign MySQL function DATE_FORMAT, or if you are using Smarty you can use date_format function.

Here is an example of Smarty date formatting:

{$smarty.now|date_format:"%d:%m:%Y"}

This will format current time, in dd-mm-yyyy format.
You can find all date conversions on smarty website.


Formatting dates using Smarty