DateFormatterConfig
Configuration options for formatting Date objects.
Examples
Section titled “Examples”// 1. ISO formatconst cfgIso: DateFormatterConfig = { method: 'ISO' };console.log(cfgIso.method); // "ISO"// 2. Epoch timestampconst cfgEpoch: DateFormatterConfig = { method: 'epoch' };console.log(cfgEpoch.method); // "epoch"// 3. Custom locale formatting: verbose French dateconst cfgCustom: DateFormatterConfig = { method: 'custom', locales: 'fr-FR', options: { year: 'numeric', month: 'long', day: 'numeric' }};const formatter = createDateFormatter(cfgCustom.locales, cfgCustom.options);console.log(formatter.format(new Date())); // e.g., "26 juillet 2025"Properties
Section titled “Properties”locales?
Section titled “locales?”
optionallocales:string|string[]
BCP 47 language tag(s) for locale-sensitive formatting when method is 'custom'.
Defaults to the host environment’s locale.
method
Section titled “method”method:
"custom"|"ISO"|"epoch"
The formatting method to apply:
'ISO'→ Returns the result ofdate.toISOString().'epoch'→ Returns the numeric timestamp (milliseconds since Unix epoch).'custom'→ UsesIntl.DateTimeFormatwith the specifiedlocalesandoptions.
options?
Section titled “options?”
optionaloptions:DateTimeFormatOptions
Formatting options (e.g., year, month, day, hour, etc.) for Intl.DateTimeFormat
when method === 'custom'.