Django 模板日期格式表

日期格式字符解析
本文详细介绍了日期格式化中使用的各种字符及其含义,包括小时、分钟、秒等的时间表示方法,以及月份、日期、年份的不同格式展示方式。还涵盖了特殊时间表达如午前午后、星期名称、是否为闰年等。

 

Format CharacterDescriptionExample Output
a'a.m.' or 'p.m.' . (Note that this is slightly different from PHPs output, because this includes periods to match Associated Press style.)'a.m.'
A'AM' or 'PM' .'AM'
bMonth, textual, three letters, lowercase'jan'
dDay of the month, two digits with leading zeros.'01' to '31'
DDay of the week, textual, three letters.'Fri'
fTime, in 12-hour hours and minutes, with minutes left off if theyre zero.'1' , '1:30'
FMonth, textual, long.'January'
gHour, 12-hour format without leading zeros.'1' to '12'
GHour, 24-hour format without leading zeros.'0' to '23'
hHour, 12-hour format.'01' to '12'
HHour, 24-hour format.'00' to '23'
iMinutes.'00' to '59'
jDay of the month without leading zeros.'1' to '31'
lDay of the week, textual, long.'Friday'
LBoolean for whether its a leap year.True or False
mMonth, two digits with leading zeros.'01' to '12'
MMonth, textual, three letters.'Jan'
nMonth without leading zeros.'1' to '12'
NMonth abbreviation in Associated Press style.'Jan.' , 'Feb.' , 'March' , 'May'
ODifference to Greenwich Mean Time in hours.'+0200'
PTime, in 12-hour hours, minutes, and a.m./p.m., with minutes left off if theyre zero and the special-case strings 'midnight' and 'noon' if appropriate.'1 a.m.' , '1:30 p.m.' , 'midnight', 'noon' , '12:30 p.m.'
rRFC 822 formatted date.'Thu, 21 Dec 2000 16:01:07 +0200'
sSeconds, two digits with leading zeros.'00' to '59'
SEnglish ordinal suffix for day of the month, two characters.'st' , 'nd' , 'rd' or 'th'
tNumber of days in the given month.28 to 31
TTime zone of this machine.'EST' , 'MDT'
wDay of the week, digits without leading zeros.'0' (Sunday) to '6' (Saturday)
WISO-8601 week number of year, with weeks starting on Monday.1 , 23
yYear, two digits.'99'
YYear, four digits.'1999'
zDay of the year.0 to 365
ZTime zone offset in seconds. The offset for time zones west of UTC is always negative, and for those east of UTC it is always positive. 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值