Moment.js format tokens.

Day.js uses the same core tokens (some, like DDD and W, need the AdvancedFormat plugin)

Letter-count tokens in the CLDR spirit, though the letters themselves diverge from CLDR (uppercase D is day of month, lowercase d is day of week). Repeating a letter usually pads or lengthens: M, MM, MMM, MMMM. Case is a trap everywhere — m is minutes while M is months, and the lowercase w/ww week tokens count locale weeks, not ISO ones. Names follow the loaded locale. There is no zone-abbreviation token: z and zz have been deprecated since 1.6.0 and only work with the moment-timezone addon. Moment itself is in maintenance mode; its authors recommend alternatives for new projects, but this vocabulary lives on in Day.js and countless codebases. Locale-aware composite tokens (L, LL, LT, LTS) format whole dates per locale.

TokenMeansExample
YYYYFour-digit year2006
YYTwo-digit year06
MMonth number

Mo gives the ordinal form (1st, 2nd).

1
MMMonth number, padded01
MMMMonth name, abbreviatedJan
MMMMMonth name, fullJanuary
DDay of month

Do gives the ordinal form (1st, 2nd).

2
DDDay of month, padded02
DDDDay of year

Unpadded; DDDD zero-pads to three digits.

2
dddWeekday, abbreviatedMon
ddddWeekday, full

A single d is the day-of-week number 0–6 (Sunday = 0), not the day of month.

Monday
WWeek of year

ISO week; WW zero-pads. Lowercase w/ww are locale weeks and count differently — not the same field.

1
GGGGISO week-based year

Pairs with W. Lowercase gggg is the locale week-year; GG is the two-digit form.

2006
HHour, 24-hour clock

k counts 1–24 instead of 0–23.

15
HHHour, 24-hour clock, padded15
hHour, 12-hour clock3
hhHour, 12-hour clock, padded03
AAM/PM marker

Lowercase a gives am/pm.

PM
mmMinute, padded

A single m gives the unpadded minute.

04
ssSecond, padded

A single s gives the unpadded second.

05
SSSFractional seconds

S/SS/SSS print one to three digits; SSSS and beyond just pad the three significant digits with zeros.

000
ZZUTC offset, basic-0700
ZUTC offset, extended-07:00
XUnix timestamp

Seconds; lowercase x gives milliseconds.

1136239445
QQuarter

Qo gives the ordinal form (1st, 2nd).

1

Examples render the reference instant, Mon, Jan 2 2006, 3:04:05 PM MST.

Literal text

Wrap literal text in square brackets: [Today is] dddd. Everything outside brackets is fair game for token interpretation.

Verified against Moment.js docs — format().

Translate Moment.js format