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.
| Token | Means | Example |
|---|---|---|
| YYYY | Four-digit year | 2006 |
| YY | Two-digit year | 06 |
| M | Month number Mo gives the ordinal form (1st, 2nd). | 1 |
| MM | Month number, padded | 01 |
| MMM | Month name, abbreviated | Jan |
| MMMM | Month name, full | January |
| D | Day of month Do gives the ordinal form (1st, 2nd). | 2 |
| DD | Day of month, padded | 02 |
| DDD | Day of year Unpadded; DDDD zero-pads to three digits. | 2 |
| ddd | Weekday, abbreviated | Mon |
| dddd | Weekday, full A single d is the day-of-week number 0–6 (Sunday = 0), not the day of month. | Monday |
| W | Week of year ISO week; WW zero-pads. Lowercase w/ww are locale weeks and count differently — not the same field. | 1 |
| GGGG | ISO week-based year Pairs with W. Lowercase gggg is the locale week-year; GG is the two-digit form. | 2006 |
| H | Hour, 24-hour clock k counts 1–24 instead of 0–23. | 15 |
| HH | Hour, 24-hour clock, padded | 15 |
| h | Hour, 12-hour clock | 3 |
| hh | Hour, 12-hour clock, padded | 03 |
| A | AM/PM marker Lowercase a gives am/pm. | PM |
| mm | Minute, padded A single m gives the unpadded minute. | 04 |
| ss | Second, padded A single s gives the unpadded second. | 05 |
| SSS | Fractional seconds S/SS/SSS print one to three digits; SSSS and beyond just pad the three significant digits with zeros. | 000 |
| ZZ | UTC offset, basic | -0700 |
| Z | UTC offset, extended | -07:00 |
| X | Unix timestamp Seconds; lowercase x gives milliseconds. | 1136239445 |
| Q | Quarter 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().