不同编程语言的格式化参数不一样!!!
Java SimpleDateFormat格式化参数:
字母 | 日期或时间元素 | 表示 | 示例 |
---|---|---|---|
G | Era 标志符 | Text | AD |
y | 年 | Year | 1996; 96 |
M | 年中的月份 | Month | July; Jul; 07 |
w | 年中的周数 | Number | 27 |
W | 月份中的周数 | Number | 2 |
D | 年中的天数 | Number | 189 |
d | 月份中的天数 | Number | 10 |
F | 月份中的星期 | Number | 2 |
E | 星期中的天数 | Text | Tuesday; Tue |
a | Am/pm 标记 | Text | PM |
H | 一天中的小时数(0-23) | Number | 0 |
k | 一天中的小时数(1-24) | Number | 24 |
K | am/pm 中的小时数(0-11) | Number | 0 |
h | am/pm 中的小时数(1-12) | Number | 12 |
m | 小时中的分钟数 | Number | 30 |
s | 分钟中的秒数 | Number | 55 |
S | 毫秒数 | Number | 978 |
z | 时区 | General time zone | Pacific Standard Time; PST; GMT-08:00 |
Z | 时区 | RFC 822 time zone | -800 |
Python datetime.datetime.strptime()格式化参数:
%a Abbreviated weekday name
本地简化星期名称
%A Full weekday name
本地完整星期名称
%b Abbreviated month name
本地简化的月份名称
%B Full month name
本地完整的月份名称
%c Date and time representation appropriate for locale
本地相应的日期表示和时间表示
%d Day of month as decimal number (01 - 31)
月内中的一天(0-31)
%H Hour in 24-hour format (00 - 23)
24 小时制小时数(0-23)
%I Hour in 12-hour format (01 - 12)
12 小时制小时数(01-12)
%j Day of year as decimal number (001 - 366)
年内的一天(001-366)
%m Month as decimal number (01 - 12)
月份(01-12)
%M Minute as decimal number (00 - 59)
分钟数(00=59)
%p Current locale's A.M./P.M. indicator for 12-hour clock
本地 A.M. 或 P.M. 的等价符
%S Second as decimal number (00 - 59)
秒(00-59)
%U Week of year as decimal number, with Sunday as first day of week (00 - 51)
一年中的星期数(00-53)星期天为星期的开始
%w Weekday as decimal number (0 - 6; Sunday is 0)
星期(0-6),星期天为星期的开始
%W Week of year as decimal number, with Monday as first day of week (00 - 51)
一年中的星期数(00-53)星期一为星期的开始
%x Date representation for current locale
本地相应的日期表示
%X Time representation for current locale
本地相应的时间表示
%y Year without century, as decimal number (00 - 9
9)
两位数的年份表示(00-99)
%Y Year with century, as decimal number
四位数的年份表示(000-9999)
%z %Z Time-zone name or abbreviation; no characters if time zone is unknown
当前时区的名称
%% Percent sign
% 号本身
ISO 8601 国际标准化组织的日期和时间的表示方法
年
Y 公元前加-
月
M
日 D
星期 w
时
hh
00到24
分
m
秒 s
毫秒 sss