How to convert timestamp to date and time format in smarty. You store the value of date and time in timestamp format. So when you display the value to user you need to convert in date and time format.If you are using smarty how you do it. You can do it in smarty using date_format modifier.
date_format in Smarty
$value_timestamp is the timestamp value you have. To convert
1 |
{$value_timestamp|date_format:"%d-%m-%Y"} |
It Prints the output like this
12-10-1982
if you use
1 |
{$value_timestamp|date_format:"%D"} |
It will display date in 23/07/2012
1 |
{$value_timestamp|date_format:"%Y-%b-%d %H:%M %p"} |
Display date like 31-Mar-2013 13:36 PM
You can display date and time in any format as per your requirement using specifiers.
Date Format specifiers in smarty
%a – abbreviated weekday name according to the current locale
%A – full weekday name according to the current locale
%b – abbreviated month name according to the current locale
%B – full month name according to the current locale
%c – preferred date and time representation for the current locale
%C – century number (the year divided by 100 and truncated to an integer, range 00 to 99)
%d – day of the month as a decimal number (range 01 to 31)
%D – same as %m/%d/%y