ChronosChronos

Format Methods

Format Methods - Chronos Documentation.

Overview

Chronos provides versatile date formatting capabilities through the format(), formatUTC(), formatSafe(), calendar() and fromNowShort(). These methods allow you to transform Chronos instances into custom string representations using a comprehensive set of format tokens. The formatting behavior is consistent across all three methods, enabling seamless switching based on your specific requirements.

Format Tokens

Info

Chronos supports a rich set of format tokens that you can use to customize how a date is displayed. These tokens work across format, formatUTC, and formatSafe methods as well as for other methods and utilities like formatDate that accept a format parameter, and behave similarly to libraries like Moment.js or Day.js.

Use square brackets ([ ]) to escape literal text. Unescaped characters will be treated as formatting tokens and replaced accordingly.

Below is a list of all supported tokens:

TokenOutputExample
or
Full year2025
or
2-digit year23
Full monthJanuary
Short monthJan
2-digit month01-12
Month1-12
2-digit day01-31
Day1-31
Ordinal day1st, 2nd
Full weekdayMonday
Short weekdayMon
Shorter weekdayMo
24-hour (00-23)09
24-hour (0-23)9
12-hour (01-12)02
12-hour (1-12)2
Minutes (00-59)05
Minutes (0-59)5
Seconds (00-59)09
Seconds (0-59)9
Milliseconds (0-999)9
Milliseconds (000-999)009
AM/PMPM
am/pmpm
TZ Offset ±HH:mm+06:00 or Z (UTC)

Note

  • To output raw text (i.e., not interpreted as a date token), wrap it in square brackets.
  • For example, [Today is] ddd results in Today is Sunday, and YYYY[ year] results in 2025 year.
  • Supported format tokens include: YYYY, YY, MMMM, MMM, MM, M, DD, D, dd, ddd, Do, HH, H, hh, h, mm, m, ss, s, ms, mss, a, A, and ZZ.
  • Any token not wrapped in brackets will be parsed and replaced with its corresponding date component.

Last updated: Wed, May 20, 2026 05:38:36PM (UTC)

On this page