Intl.DateTimeFormat.prototype.resolvedOptions()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2017.
The resolvedOptions() method of Intl.DateTimeFormat instances returns a new object with properties reflecting the options computed during initialization of this DateTimeFormat object.
Try it
const region = new Intl.DateTimeFormat("zh-CN", { timeZone: "UTC" });
const options = region.resolvedOptions();
console.log(options.locale);
// Expected output: "zh-CN"
console.log(options.calendar);
// Expected output: "gregory"
console.log(options.numberingSystem);
// Expected output: "latn"
Syntax
resolvedOptions()
Parameters
None.
Return value
A new object with properties reflecting the options computed during the initialization of this DateTimeFormat object. The object has the following properties, in the order they are listed:
locale-
The BCP 47 language tag for the locale actually used, determined by the locale negotiation process. Only the
ca,hc, andnuUnicode extension keys, if requested, may be included in the output. calendar-
The value provided for this property in the
optionsargument, or using the Unicode extension key"ca", with default filled in as needed. It is a supported calendar type for this locale. The default is locale dependent. numberingSystem-
The value provided for this property in the
optionsargument, or using the Unicode extension key"nu", with default filled in as needed. It is a supported numbering system for this locale. The default is locale dependent. timeZone-
The value provided for this property in the
optionsargument, with default filled in as needed. It is an IANA time zone name. The default is the runtime's default time zone.Note: The standardization of
Temporalrequires browsers to use the same identifier as originally specified, without canonicalization to a different alias. See time zones and offsets for more information. hourCycleOptional-
The value provided for this property in the
optionsargument, or using the Unicode extension key"hc", with default filled in as needed. Ifhour12was provided in theoptions, then that overrides otherhourCyclesettings. It is only present if the resolved options also includehourortimeStyle. It is either"h11","h12","h23", or"h24". The default is locale dependent, although"h24"is never a default. hour12Optional-
Calculated from
hourCycle. It is only present if the resolved options also includehourortimeStyle. It istrueifhourCycleis"h11"or"h12", andfalseifhourCycleis"h23"or"h24". weekday,era,year,month,day,dayPeriod,hour,minute,second,fractionalSecondDigits,timeZoneNameOptional-
The values resulting from format matching between the corresponding properties in the
optionsargument and the available combinations and representations for date-time formatting in the selected locale. Some of these properties may not be present, indicating that the corresponding components will not be represented in formatted output.weekday,era, anddayPeriodare either"narrow","short", or"long";year,day,hour,minute, andsecondare either"numeric","2-digit", or"narrow";monthis either"numeric","2-digit","narrow","short", or"long";fractionalSecondDigitsis either1,2, or3;timeZoneNameis either"short","long","shortOffset","longOffset","shortGeneric", or"longGeneric".If these properties were requested in
options, the constructor preventsdateStyleandtimeStylefrom being specified, so the below group will never be present. dateStyle,timeStyleOptional-
The values provided for these properties in the
optionsargument. They are either"full","long","medium","short", or"none". Some of these properties may not be present, indicating that the corresponding components will not be represented in formatted output.If these properties were requested in
options, the constructor prevents individual date time component options from being specified, so the above group will never be present.Note: Although
dateStyleandtimeStyleare shortcuts for individual date and time component styles, the exact (locale dependent) component styles they resolve to are not included in the resolved options. This ensures the result ofresolvedOptions()can be passed directly to theIntl.DateTimeFormat()constructor (because anoptionsobject with bothdateStyleortimeStyleand individual date or time component styles is not valid).
Examples
>Using the resolvedOptions method
const germanFakeRegion = new Intl.DateTimeFormat("de-XX", { timeZone: "UTC" });
const usedOptions = germanFakeRegion.resolvedOptions();
usedOptions.locale; // "de" (because "de-XX" does not exist)
usedOptions.calendar; // "gregory"
usedOptions.numberingSystem; // "latn"
usedOptions.timeZone; // "UTC"
usedOptions.month; // "numeric"
Getting the user's time zone and locale preferences
The Intl.DateTimeFormat constructor without any options uses the current system settings. You can use resolvedOptions() to get the user's current time zone and locale's preferred calendar and numbering system:
const systemOptions = new Intl.DateTimeFormat().resolvedOptions();
systemOptions.timeZone; // e.g., "Europe/Brussels" or "Asia/Riyadh"
systemOptions.calendar; // e.g., "gregory" or "islamic-umalqura"
systemOptions.numberingSystem; // e.g., "latn" or "arab"
systemOptions.locale; // e.g., "nl-BE" or "ar-SA"
Specifications
| Specification |
|---|
| ECMAScript® 2026 Internationalization API Specification> # sec-intl.datetimeformat.prototype.resolvedoptions> |
Browser compatibility
Loading…