How to convert timestamp to date format in smarty template

Leave a Comment

How to convert timestamp to date format in smarty 


There is many occassion when you query the database and you get the value in timestamp format
now you need to convert it into the date format.

suppose you get the value of date in timestamp


Now you need to convert it into the format of 23-07-2012 how you do it in smarty

$value is the timestamp value you get. Now use date_format in smarty and use specifier to get the format on which you require

{$value|date_format:"%d-%m-%Y"}

display date in

12-07-1988


if you use

{$value|date_format:"%D"}

It will display date in

23/07/2012

Some of the specifier are


%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

For complete specifier check the link
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment