做網站,我們是認真的!

網站適配電腦+手機端,僅1280元,送2000M阿里云服務器,送com域名+免費備案
網站前端采用靜態系統顯示,后端動態管理,我們承諾網站包收錄,完成網站之后把源碼給客戶!

觀點

互聯網+時代,說建站,談運營與網絡營銷

smarty 時間格式化date_format

時間:2021-07-03

代碼如下:
$smarty = new Smarty;
$smarty->assign('yesterday', strtotime('-1 day'));
$smarty->display('index.tpl');
index.tpl:
{$smarty.now|date_format}
{$smarty.now|date_format:"%A, %B %e, %Y"}
{$smarty.now|date_format:"%H:%M:%S"}
{$yesterday|date_format}
{$yesterday|date_format:"%A, %B %e, %Y"}
{$yesterday|date_format:"%H:%M:%S"}


輸出代碼如下:
Feb 6, 2001
Tuesday, February 6, 2001
:33:00
Feb 5, 2001
Monday, February 5, 2001
:33:00

常用格式:{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}   顯示2010-05-16 05:20:14

更多請參看smarty手冊,下面只作簡單幾個介紹。。

kc - 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
(根據當地格式輸出“月”全稱格式)

0
首頁
案例
關于
聯系
开云投注