format
Formats a date as a short label that does not depend on the machine: UTC, English, and
Jul 27, 2026 by default. A shorthand for
formatInTimezone(date, 'UTC', { locale, formatOptions }).
formatOptions replaces the default format rather than extending it, so
{ month: 'short', day: 'numeric' } gives Jul 27 with no year.
Returns null if the date or the locale is invalid.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
date | DateLike | The date to format |
formatOptions | DateTimeFormatOptions | `Intl.DateTimeFormat` options (default: day, short month, year) |
locale | string | BCP 47 locale tag (default: `‘en’`) |
Returns
Section titled “Returns”string | null — The formatted date, or null
Examples
Section titled “Examples”format
Section titled “format”Related Types
Section titled “Related Types”DateLike
Section titled “DateLike”A value that can be converted to a Date.
Date— used as-is (validated for Invalid Date)number— treated as a timestamp (seconds or milliseconds, auto-detected);0is treated as invalid and producesnullin ensureDatestring— parsed vianew Date(string)Temporal.Instant|Temporal.ZonedDateTime— read via theirepochMillisecondsproperty
