smarty學習1date_format

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

時間戳轉(zhuǎn)日期{$user.create_time|date_format}

{$user.create_time|date_format:"%A, %B %e, %Y"}

{$user.create_time|date_format:"%H:%M:%S"}

時間戳轉(zhuǎn)日期

下面是所有格式輸出

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

(根據(jù)當?shù)馗袷捷敵觥靶瞧凇笨s寫格式)星期的簡稱,例如"Mon"星期一

%A - full weekday name according to the current locale

(根據(jù)當?shù)馗袷捷敵觥靶瞧凇比Q格式)例如"Monday"

%b - abbreviated month name according to the current locale

(根據(jù)當?shù)馗袷捷敵觥霸隆笨s寫格式)

%B - full month name according to the current locale

(根據(jù)當?shù)馗袷捷敵觥霸隆比Q格式)

%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)

顯示當前日期的數(shù)字 例如"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)

顯示當前日期的數(shù)字 例如"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時區(qū)名稱或縮寫%% - a literal `%' character


還有解決不了的歡迎留言,也可以訪問我的微博,知無不言,菜鳥一枚,感謝觀看? ? http://weibo.com/rosekissyou

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末躁染,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子私痹,更是在濱河造成了極大的恐慌表谊,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,273評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異苹丸,居然都是意外死亡,警方通過查閱死者的電腦和手機苇经,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,349評論 3 398
  • 文/潘曉璐 我一進店門赘理,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人扇单,你說我怎么就攤上這事商模。” “怎么了令花?”我有些...
    開封第一講書人閱讀 167,709評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長凉倚。 經(jīng)常有香客問我兼都,道長,這世上最難降的妖魔是什么稽寒? 我笑而不...
    開封第一講書人閱讀 59,520評論 1 296
  • 正文 為了忘掉前任扮碧,我火速辦了婚禮,結(jié)果婚禮上杏糙,老公的妹妹穿的比我還像新娘慎王。我一直安慰自己,他們只是感情好宏侍,可當我...
    茶點故事閱讀 68,515評論 6 397
  • 文/花漫 我一把揭開白布赖淤。 她就那樣靜靜地躺著,像睡著了一般谅河。 火紅的嫁衣襯著肌膚如雪咱旱。 梳的紋絲不亂的頭發(fā)上确丢,一...
    開封第一講書人閱讀 52,158評論 1 308
  • 那天,我揣著相機與錄音吐限,去河邊找鬼鲜侥。 笑死,一個胖子當著我的面吹牛诸典,可吹牛的內(nèi)容都是我干的描函。 我是一名探鬼主播,決...
    沈念sama閱讀 40,755評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼狐粱,長吁一口氣:“原來是場噩夢啊……” “哼舀寓!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起脑奠,我...
    開封第一講書人閱讀 39,660評論 0 276
  • 序言:老撾萬榮一對情侶失蹤基公,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后宋欺,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體轰豆,經(jīng)...
    沈念sama閱讀 46,203評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,287評論 3 340
  • 正文 我和宋清朗相戀三年齿诞,在試婚紗的時候發(fā)現(xiàn)自己被綠了酸休。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,427評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡祷杈,死狀恐怖斑司,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情但汞,我是刑警寧澤宿刮,帶...
    沈念sama閱讀 36,122評論 5 349
  • 正文 年R本政府宣布,位于F島的核電站私蕾,受9級特大地震影響僵缺,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜踩叭,卻給世界環(huán)境...
    茶點故事閱讀 41,801評論 3 333
  • 文/蒙蒙 一磕潮、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧容贝,春花似錦自脯、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,272評論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至满力,卻和暖如春戏罢,著一層夾襖步出監(jiān)牢的瞬間屋谭,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,393評論 1 272
  • 我被黑心中介騙來泰國打工龟糕, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留桐磁,地道東北人。 一個月前我還...
    沈念sama閱讀 48,808評論 3 376
  • 正文 我出身青樓讲岁,卻偏偏與公主長得像我擂,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子缓艳,可洞房花燭夜當晚...
    茶點故事閱讀 45,440評論 2 359

推薦閱讀更多精彩內(nèi)容