What date and time formats are supported with tokens?

Based on standard Unicode Tokens

Format
Output
Description

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

Shortcut Format
Format
Sample Output

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.

Format
Example
Action

+<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