Skip to main content

Custom Display Format for Date/Time


Frequently used format rules for date/time display

RuleDisplay
YearYY70 71 ... 29 30 (last two digits of the year)
YYYY1970 1971 ... 2029 2030
MonthM1 2 ... 11 12
MM01 02 ... 11 12 (Number less than 10 is preceded by 0)
MMMJan Feb…Nov Dec
MMMMJanuary Febrary…November December
DayD1 2 ... 30 31
DD01 02 ... 30 31
Days in a yearDDD1 2 ... 364 365
DDDD001 002 ... 364 365
Days in a weekd0 1 ... 5 6
dddSun Mon… Fri Sat
ddddSunday Monday…Friday Saturday
E1 2 ... 6 7
Weeks in a yearw1 2 ... 52 53
ww01 02 ... 52 53
QuarterQ1 2 3 4
Morning/AfternoonAAM PM
HourH0 1 ... 22 23 (24-hour system)
HH00 01 ... 22 23
h1 2 ... 11 12 (12-hour system)
hh01 02 ... 11 12
Minutem0 1 ... 58 59
mm00 01 ... 58 59
Seconds0 1 ... 58 59
ss00 01 ... 58 59
MillisecondSSS001 002 ... 998 999
Time ZoneZ+08:00
ZZ+0800

Note: MM and mm are case-sensitive for months and minutes, respectively; other rules are not case-sensitive.

With the rules above and the connectors (-/year, month, day, etc.) you can get the desired format.

Example

Take [2021-09-15 15:09:18] as an example.

RuleDisplay
YYYY/MM/DD2021/09/15
YYYYMMDD20210915
YYMMDD210915
YYYYMMDDHHmmss20210915150918
YYYYMMDD HHmmss20210915 150918
YYYYMMDDHHmmssSSS20210915150918317

Have questions about this article? Send us feedback