smarty 时间格式化date_format
代码如下:
$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手册,下面只作简单几个介绍。。
%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
(根据当地格式输出“月”全称格式)
最新文章
- 将 VMware 最小化到系统托盘
- Ruby on rails学习笔记——安装环境
- [ASP.NET] 下一代ASP.NET开发规范:OWIN
- Spring的replace-method标签
- javabean与map互转
- POJ 2127
- WiFi安全之WPA介绍
- DJANGO的ORM的Q查询作多字段外键的模糊查询样码
- h2database源码浅析:TransactionMap、MVMap、MVStore
- C#日期格式精确到毫秒以及上下午
- 360极速浏览器在XP系统下的一个bug
- ID选择器
- JSON 基本语法
- 实战DeviceIoControl 之四:获取硬盘的详细信息
- 安装Oracle Grid的过程中用到的几个小技巧
- 小程序快捷键(mac中)
- Linux 禁止root 用户登录启用sudo
- codeforces 678C. Joty and Chocolate(容斥) 2016-10-15 21:49 122人阅读 评论(0) 收藏
- 结合 RunLoop 和 Instrument 定位卡顿
- webservice的 发布
热门文章
- 修改msconfig->;引导->;高级选项-》最大内存为512M
- HTML+CSS学习笔记(4) - 认识标签(3)
- spring aop配置及用例说明(1)
- CAF(C++ actor framework)使用随笔(延迟发送,消息转发,消息优先级)(四)
- Qt自绘窗体
- fedora下python3 安装tkinter和pygame
- 一种C# TCP异步编程中遇到的问题
- OWIN OAuth 2.0 Authorization Server
- 多线程的单元测试工具 - GroboUtils
- xaml中绑定单例属性