formatDate

Commons
stable

Format a Date object using a named format string (e.g. "fullDate", "shortDate", "monthAndYear") with locale-aware output via Intl.DateTimeFormat. Supports custom format functions via a formats map.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

A simpler overload also exists in packages/ds/src/utils/Calendar/date.util.ts with signature (date, locale, options: Intl.DateTimeFormatOptions) for direct Intl option objects.

API

Parameters

Input parameters accepted by this util.

date
required
Date
locale
required
string
BCP 47 locale tag used by Intl.DateTimeFormat, e.g. 'en-US' or 'fr-FR'.
options
required
Intl.DateTimeFormatOptions

API

Return value

The value returned by this util.

Locale-formatted date string.

Usage

Examples

Ready-to-paste usage snippets.

Format using a named preset

typescript