createDateFormatter
createDateFormatter(
locales?
,options?
):DateTimeFormat
Creates an Intl.DateTimeFormat for formatting dates and times.
If both locales
and options
are omitted, returns a shared
default formatter instance.
Parameters
Section titled “Parameters”locales?
Section titled “locales?”BCP 47 language tag(s) to use. Defaults to the host environment’s locale.
string
| string
[]
options?
Section titled “options?”DateTimeFormatOptions
Formatting options (year, month, day, hour, minute, second, fractionalSecondDigits).
Returns
Section titled “Returns”DateTimeFormat
A date-time formatter configured with the specified locales and options.
Example
Section titled “Example”// Default formatting (e.g., "2025-07-26 16:32:10.123")const fmt = createDateFormatter();console.log(fmt.format(new Date()));
@example// French month and dayconst fmtFr = createDateFormatter('fr-FR', { month: 'long', day: 'numeric' });console.log(fmtFr.format(new Date())); // e.g., "26 juillet"