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

Signature TypeScript complète, extraite du fichier util.

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

Paramètres

Paramètres d'entrée acceptés par cet util.

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

API

Valeur de retour

La valeur retournée par cet util.

Locale-formatted date string.

Usage

Exemples

Extraits de code prêts à coller.

Format using a named preset

typescript