1 日期格式化
获取当前时间
{$smarty.now|date_format}//Jan 13, 2017{$smarty.now|date_format:"%A, %B %e, %Y"}//Friday, January 13, 2017{$smarty.now|date_format:"%H:%M:%S"}//12:13:46
时间戳转日期{$user.create_time|date_format}
{$user.create_time|date_format:"%A, %B %e, %Y"}
{$user.create_time|date_format:"%H:%M:%S"}
时间戳转日期
下面是所有格式输出
date_format-- Jan 13, 2017
%a-- Fri
%A-- Friday
%b-- Jan
%B-- January
%c-- 01/13/17 12:51:45
%C--
%d-- 13
%D-- 01/13/17
%e-- 13
%g--
%G--
%h-- Jan
%H-- 12
%I-- 12
%j-- 013
%k--
%l-- 12
%m-- 01
%M-- 51
%n--
%p-- PM
%r-- 12:51:45 PM
%R-- 12:51
%S-- 45
%t--
%T-- 12:51:45
%u --
%U-- 02
%V--
%W-- 02
%w-- 5
%x-- 01/13/17
%Y-- 2017
%X-- 12:51:45
%Z-- �й���ʱ��
%z-- �й���ʱ��
%%-- %
这里附加输出源码
date_format-- {$smarty.now|date_format}
%a-- {$smarty.now|date_format:"%a"}
%A-- {$smarty.now|date_format:"%A"}
%b-- {$smarty.now|date_format:"%b"}
%B-- {$smarty.now|date_format:"%B"}
%c-- {$smarty.now|date_format:"%c"}
%C-- {$smarty.now|date_format:"%C"}
%d-- {$smarty.now|date_format:"%d"}
%D-- {$smarty.now|date_format:"%D"}
%e-- {$smarty.now|date_format:"%e"}
%g-- {$smarty.now|date_format:"%g"}
%G-- {$smarty.now|date_format:"%G"}
%h-- {$smarty.now|date_format:"%h"}
%H-- {$smarty.now|date_format:"%H"}
%I-- {$smarty.now|date_format:"%I"}
%j-- {$smarty.now|date_format:"%j"}
%k-- {$smarty.now|date_format:"%k"}
%l-- {$smarty.now|date_format:"%l"}
%m-- {$smarty.now|date_format:"%m"}
%M-- {$smarty.now|date_format:"%M"}
%n-- {$smarty.now|date_format:"%n"}
%p-- {$smarty.now|date_format:"%p"}
%r-- {$smarty.now|date_format:"%r"}
%R-- {$smarty.now|date_format:"%R"}
%S-- {$smarty.now|date_format:"%S"}
%t-- {$smarty.now|date_format:"%t"}
%T-- {$smarty.now|date_format:"%T"}
%u -- {$smarty.now|date_format:"%u"}
%U-- {$smarty.now|date_format:"%U"}
%V-- {$smarty.now|date_format:"%V"}
%W-- {$smarty.now|date_format:"%W"}
%w-- {$smarty.now|date_format:"%w"}
%x-- {$smarty.now|date_format:"%x"}
%Y-- {$smarty.now|date_format:"%Y"}
%X-- {$smarty.now|date_format:"%X"}
%Z-- {$smarty.now|date_format:"%Z"}
%z-- {$smarty.now|date_format:"%z"}
%%-- {$smarty.now|date_format:"%%"}
%a - abbreviated weekday name according to the current locale
(根据当地格式输出“星期”缩写格式)星期的简称,例如"Mon"星期一
%A - full weekday name according to the current locale
(根据当地格式输出“星期”全称格式)例如"Monday"
%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
以"01/13/17 12:25:23"形式显示当前时间%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 00 to 31)
显示当前日期的数字 例如"13"
%D - same as %m/%d/%y
以 "01/13/17"显示当前日期%e - day of the month as a decimal number, a single digit is preceded by a
space (range 1 to 31)
显示当前日期的数字 例如"13"
%g - Week-based year within century [00,99]
%G - Week-based year, including the century [0000,9999]
%h - same as %b
%H - hour as a decimal number using a 24-hour clock (range 00 to 23)
%I - hour as a decimal number using a 12-hour clock (range 01 to 12)
%j - day of the year as a decimal number (range 001 to 366)
%k - Hour (24-hour clock) single digits are preceded by a blank. (range 0 to 23)
%l - hour as a decimal number using a 12-hour clock, single digits preceeded by
a space (range 1 to 12)
%m - month as a decimal number (range 01 to 12)
%M - minute as a decimal number
%n - newline character
%p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale
%r - time in a.m. and p.m. notation
%R - time in 24 hour notation
%S - second as a decimal number
%t - tab character
%T - current time, equal to %H:%M:%S
%u - weekday as a decimal number [1,7], with 1 representing Monday
%U - week number of the current year as a decimal number, starting with the first Sunday as the first day of the first week
%V - The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1
is the first week that has at least 4 days in the current year, and with Monday as the first day of the week.
%w - day of the week as a decimal, Sunday being 0
%W - week number of the current year as a decimal number, starting with the first Monday as the first day of the first week
%x - preferred date representation for the current locale without the time
%X - preferred time representation for the current locale without the date
%y - year as a decimal number without a century (range 00 to 99)
%Y - year as a decimal number including the century
%Z - time zone or name or abbreviation时区名称或缩写%% - a literal `%' character
还有解决不了的欢迎留言,也可以访问我的微博,知无不言,菜鸟一枚,感谢观看 http://weibo.com/rosekissyou