php Smarty date_format [格式化时间日期]

Example 5-8. date_format[日期格式] 
index.php:

复制代码代码如下:

$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"}

OUTPUT:

复制代码代码如下:

Feb 6, 2001 
Tuesday, February 6, 2001 
:33:00 
Feb 5, 2001 
Monday, February 5, 2001 
:33:00

Example 5-9. date_format conversion specifiers[日期转换说明]

复制代码代码如下:

%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 00 to 31) 
%D - same as %m/%d/%y 
%e - day of the month as a decimal number, a single digit is preceded by a 
space (range 1 to 31) 
%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

PROGRAMMERS NOTE: date_format is essentially a wrapper to PHP‘s strftime() 
function. You may have more or less conversion specifiers available depending 
on your system‘s strftime() function where PHP was compiled. Check your 
system‘s manpage for a full list of valid specifiers. 
程序员提示:date_format本质上是php的strftime()函数的一个包装。 
当php被编译的时候你可以或多或少的依靠系统的strftime()转换有效的区分符。 
可以查看系统手册的有效区分符的全表.

php Smarty date_format [格式化时间日期]

时间: 2024-07-29 02:32:36

php Smarty date_format [格式化时间日期]的相关文章

js 格式化时间日期函数小结

下面是脚本之家为大家整理的一些格式化时间日期的函数代码,需要的朋友可以参考下. 代码如下: Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinutes(

js 格式化时间日期

Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinutes(), //minute "s+" : this.getSeconds()

Java中的时间日期处理

程序就是输入——>处理——>输出.对数据的处理是程序员需要着重注意的地方,快速.高效的对数据进行处理时我们的追求.其中,时间日期的处理又尤为重要和平凡,此次,我将把Java中的时间日期处理方式进行简单的解析,为自己以后的学习做一个备忘,也为初学者做一个借鉴. 时间,英文Time:日期,英文Date:日历,英文Calendar.Java中注重语义化,也是用以上的名称对时间日期函数和相关类进行命名. 我们将以Java自带的时间日期类和其中的处理函数进行分析. 一.与时间日期有关的类. java.u

Js获取当前日期时间+日期印证+判断闰年+日期的天数差+日期格式化+JS判断某年某月有多少天

Js获取当前日期时间+日期验证+判断闰年+日期的天数差+日期格式化+JS判断某年某月有多少天 字符串转日期型+Js当前日期时间+日期验证+判断闰年+日期的天数差+日期格式化+日期所在年的第几周 日期时间脚本库方法列表Date.prototype.isLeapYear 判断闰年Date.prototype.Format 日期格式化Date.prototype.DateAdd 日期计算Date.prototype.DateDiff 比较日期差Date.prototype.toString 日期转字符

python中时间日期格式化符号

python中时间日期格式化符号: %y 两位数的年份表示(00-99) %Y 四位数的年份表示(000-9999) %m 月份(01-12) %d 月内中的一天(0-31) %H 24小时制小时数(0-23) %I 12小时制小时数(01-12) %M 分钟数(00=59) %S 秒(00-59) %a 本地简化星期名称 %A 本地完整星期名称 %b 本地简化的月份名称 %B 本地完整的月份名称 %c 本地相应的日期表示和时间表示 %j 年内的一天(001-366) %p 本地A.M.或P.M

Java中时间日期格式化

1.与日期时间相关的类:      第一:java.util.Date;                         将时间作为一个整体使用.处理时,使用Date类较为简便      第二:java.util.Calender;                   要处理时间的一部分,如月.分时,使用Calendar类较为简便      第三:java.text.DateFormat               抽象类,是SimpleDateFormate的父类      第四:java.t

java向mysql插入时间,时间日期格式化

java向MySQL插入当前时间的几种方式和java时间日期格式化的几种方法:(资料参考网络资源) 1. java向MySQL插入当前时间的几种种方式 第一种:将java.util.Date类型的时间转成mysql数据库识别的java.sql.Date类型时间 注:java.util.Date是java.sql.Date的父类 向上转型:我定义了一个子类Cat,它继承了Animal类,那么后者就是前者是父类. 通过 Cat c = new Cat(); 实例化一个Cat的对象,但当我这样定义时:

(转)java向MySQL插入当前时间的四种方式和java时间日期格式化的几种方法(案例说明)

java向MySQL插入当前时间的四种方式和java时间日期格式化的几种方法(案例说明);部分资料参考网络资源 1. java向MySQL插入当前时间的四种方式 第一种:将java.util.Date类型的时间转成mysql数据库识别的java.sql.Date类型时间 注:java.util.Date是java.sql.Date的父类 Date time= new java.sql.Date(newjava.util.Date().getTime()); 第二种: java用PreparedS

python对时间日期做格式化

python对时间日期做格式化 >>> import datetime >>> dir(datetime) ['MAXYEAR', 'MINYEAR', '__doc__', '__file__', '__name__', '__package__', 'date', 'datetime', 'datetime_CAPI', 'time', 'timedelta', 'tzinfo'] >>> datetime.datetime.now() datet