Understanding Date/Time Formats

Date and time may be represented by a wide variety of tokens. We provide here a quick reference, adapted from Moment.js interface documentation.

Tokens for Date and Time Representation, with Examples
Token Input Example Description
Y YYYY 2014 4- or 2-digit year
YY 14 2-digit year
Y -25

Year with any number of digits and a sign.

Used for years that are not in 4-digit form, and for years Before the Common Era.

Q Q 1..4 Quarter of year. Sets the month to the first month in quarter.
M M MM 1..12 Month number
  MMM MMMM Jan..December Month name in locale set by moment.locale()
D and d D DD 1..31 Day of month
  Do 1st..31st Day of month with ordinal
  DDD DDDD 1..365 Day of year
  ddd dddd Mon...Sunday Day name in locale set by moment.locale()
X and x X 1410715640.579 Unix timestamp
x 1410715640579 Unix ms timestamp
G and g GGGG 2014 ISO 4-digit week year
GG 14 ISO 2-digit week year
gggg 2014 Locale 4-digit week year
gg 14 Locale 2-digit week year
W and w W WW 1..53 ISO week of year
  w ww 1..53 Locale week of year
E and e E 1..7 ISO day of week
  e 0..6 Locale day of week
H and h H HH 0..23 24-hour time
  h hh 1..12 12-hour time used with a and A
A and a a A am pm

Post- or ante-meridian.

Note that one character a or p are also valid.

m m mm 0..59 Minutes
s and S s ss 0..59 Seconds
  S SS SSS 0.999 Fractional seconds
Z Z ZZ +12:00 Offset from UTC, as +-HH:mm, +-HHmm, or Z.