Date 格式参数如何设置?

知晓云 - 小晓云发表于:2017年09月21日 11:02:12更新于:2019年02月14日 11:28:53

Format characterDescriptionExample output
a'a.m.' or 'p.m.' (Note that this is slightly different than PHP’s output, because this includes periods to match Associated Press style.)'a.m.'
A'AM' or 'PM'.'AM'
bMonth, textual, 3 letters, lowercase.'jan'
BNot implemented.
cISO 8601 format. (Note: unlike others formatters, such as “Z”, “O” or “r”, the “c” formatter will not add timezone offset if value is a naive datetime (see datetime.tzinfo).2008-01-02T10:30:00.000123+02:00, or 2008-01-02T10:30:00.000123 if the datetime is naive
dDay of the month, 2 digits with leading zeros.'01' to '31'
DDay of the week, textual, 3 letters.'Fri'
eTimezone name. Could be in any format, or might return an empty string, depending on the datetime.'''GMT''-500''US/Eastern', etc.
EMonth, locale specific alternative representation usually used for long date representation.'listopada' (for Polish locale, as opposed to 'Listopad')
fTime, in 12-hour hours and minutes, with minutes left off if they’re zero. Proprietary extension.'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'
IDaylight Savings Time, whether it’s in effect or not.'1' or '0'
jDay of the month without leading zeros.'1' to '31'
lDay of the week, textual, long.'Friday'
LBoolean for whether it’s a leap year.True or False
mMonth, 2 digits with leading zeros.'01' to '12'
MMonth, textual, 3 letters.'Jan'
nMonth without leading zeros.'1' to '12'
NMonth abbreviation in Associated Press style. Proprietary extension.'Jan.''Feb.''March''May'
oISO-8601 week-numbering year, corresponding to the ISO-8601 week number (W) which uses leap weeks. See Y for the more common year format.'1999'
ODifference to Greenwich time in hours.'+0200'
PTime, in 12-hour hours, minutes and ‘a.m.’/’p.m.’, with minutes left off if they’re zero and the special-case strings ‘midnight’ and ‘noon’ if appropriate. Proprietary extension.'1 a.m.''1:30 p.m.''midnight''noon''12:30p.m.'
rRFC 5322 formatted date.'Thu, 21 Dec 2000 16:01:07 +0200'
sSeconds, 2 digits with leading zeros.'00' to '59'
SEnglish ordinal suffix for day of the month, 2 characters.'st''nd''rd' or 'th'
tNumber of days in the given month.28 to 31
TTime zone of this machine.'EST''MDT'
uMicroseconds.000000 to 999999
USeconds since the Unix Epoch (January 1 1970 00:00:00 UTC).
wDay of the week, digits without leading zeros.'0' (Sunday) to '6' (Saturday)
WISO-8601 week number of year, with weeks starting on Monday.153
yYear, 2 digits.'99'
YYear, 4 digits.'1999'
zDay of the year.0 to 365
ZTime zone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.-43200 to 43200


知晓云-小程序开发快人一步

回复(1)

  • P02

    看到脑壳痛。。。

您需要登录后才可以回复