Skip to content

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.

BCP 47 language tag(s) to use. Defaults to the host environment’s locale.

string | string[]

DateTimeFormatOptions

Formatting options (year, month, day, hour, minute, second, fractionalSecondDigits).

DateTimeFormat

A date-time formatter configured with the specified locales and options.

https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#parameters

// Default formatting (e.g., "2025-07-26 16:32:10.123")
const fmt = createDateFormatter();
console.log(fmt.format(new Date()));
@example
// French month and day
const fmtFr = createDateFormatter('fr-FR', { month: 'long', day: 'numeric' });
console.log(fmtFr.format(new Date())); // e.g., "26 juillet"