What date and time formats are supported with tokens?
Based on standard Unicode Tokens
yy
18
Two-digit year
yyyy
2018
Four-digit year
M
1-12
The month, beginning at 1
MM
01-12
The month, 2-digits
MMM
Jan-Dec
The abbreviated month name
MMMM
January-December
The full month name
d
1-31
The day of the month
dd
01-31
The day of the month, 2-digits
eeeeee
Su-Sa
The min name of the day of the week
eee
Sun-Sat
The short name of the day of the week
eeee
Sunday-Saturday
The name of the day of the week
H
0-23
The hour
HH
00-23
The hour, 2-digits
h
1-12
The hour, 12-hour clock
hh
01-12
The hour, 12-hour clock, 2-digits
m
0-59
The minute
mm
00-59
The minute, 2-digits
s
0-59
The second
ss
00-59
The second, 2-digits
S+
000-999
The millisecond, 3-digits
xxx
+05:00
The offset from UTC, Β±HH:mm
xxxx
+0500
The offset from UTC, Β±HHmm
a
AM PM
aaa
am pm
LT
h:mm a
8:02 PM
LTS
h:mm:ss a
8:02:18 PM
l
M/d/yyyy
8/16/2018
ll
MMM d, yyyy
Aug 16, 2018
Mutations
We can add extra | ...
to the format string to mutate current date-time. For example, yyyy-mm-dd|+5
to add 5 days
to current date.
+<N>s
hh:ss|+30s
β to add 30
seconds
to add <N>
seconds to current date-time
-<N>s
hh:ss|-30s
β to subtract 30
seconds
to subtract <N>
seconds from current date-time
+<N>m
hh:ss|+10m
β to add 10
minutes
to add <N>
minutes to current date-time
-<N>m
hh:ss|-10m
β to subtract 10
minutes
to subtract <N>
minutes from current date-time
+<N>h
hh:ss|+2h
β to add 2
hours
to add <N>
hours to current date-time
-<N>h
hh:ss|-2h
β to subtract 2
hours
to subtract <N>
hours from current date-time
+<N>y
yyyy-mm-dd|+1y
β to add 1
year
to add <N>
years to current date-time
-<N>y
yyyy-mm-dd|-1y
β to subtract 1
year
to subtract <N>
years from current date-time
+<N>d
yyyy-mm-dd|+1d
β to add 1
day
to add <N>
days to current date-time
-<N>d
yyyy-mm-dd|-1d
β to subtract 1
days
to subtract <N>
days from current date-time
+<N>M
yyyy-mm-dd|+1M
β to add 1
month
to add <N>
months to current date-time
-<N>M
yyyy-mm-dd|-1M
β to subtract 1
month
to subtract <N>
months from current date-time
+<N>
yyyy-mm-dd|+1
β to add 1
day
to add <N>
days to current date-time
-<N>
yyyy-mm-dd|-1
β to subtract 1
days
to subtract <N>
days from current date-time
Last updated