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.
2 comments:
hey, thanks much for the tip, was looking for something just like this for my site.
here is a good website for helping format dates using the date_format function mysqlformatdate.com
Post a Comment