The resolvedOptions() method of Intl.DurationFormat instances returns a new object with properties reflecting the locale and date and time formatting options computed during initialization of this Intl.DurationFormat object.
Syntax
resolvedOptions()
Parameters
None.
Return value
A new object with properties reflecting the locale and date and time formatting options computed during the initialization of the given Intl.DateTimeFormat object.
Description
The resulting object has the following properties:
locale- : The BCP 47 language tag for the locale used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in
locale.
- : The BCP 47 language tag for the locale used. If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are supported for this locale are included in
style- : One of the strings
"long","short","narrow", or"digital"identifying the duration formatting style used.
- : One of the strings
years- : One of the strings
"long","short", or"narrow"identifying the formatting style used for theyearsfield.
- : One of the strings
yearsDisplay- : One of the strings
"auto"or"always"identifying when to display theyearsfield.
- : One of the strings
months- : One of the strings
"long","short",and "narrow"identifying the formatting style used for themonthsfield.
- : One of the strings
monthsDisplay- : One of the strings
"auto"or"always"identifying when to display themonthsfield.
- : One of the strings
weeks- : One of the strings
"long","short",and "narrow"identifying the formatting style used for theweeksfield.
- : One of the strings
weeksDisplay- : One of the strings
"auto"or"always"identifying when to display theweeksfield.
- : One of the strings
days- : One of the strings
"long","short", and"narrow"identifying the formatting style used for thedaysfield.
- : One of the strings
daysDisplay- : One of the strings
"auto"or"always"identifying when to display thedaysfield.
- : One of the strings
hours- : One of the strings
"long","short","narrow","2-digit", or"numeric"identifying the formatting style used for thehoursfield.
- : One of the strings
hoursDisplay- : One of the strings
"auto"or"always"identifying when to display thehoursfield.
- : One of the strings
minutes- : One of the strings
"long","short","narrow","2-digit", or"numeric"identifying the formatting style used for theminutesfield.
- : One of the strings
minutesDisplay- : One of the strings
"auto"or"always"identifying when to display theminutesfield.
- : One of the strings
seconds- : One of the strings
"long","short","narrow","2-digit", or"numeric"identifying the formatting style used for thesecondsfield.
- : One of the strings
secondsDisplay- : One of the strings
"auto"or"always"identifying when to display thesecondsfield.
- : One of the strings
milliseconds- : One of the strings
"long","short","narrow", or"numeric"identifying the formatting style used for themillisecondsfield.
- : One of the strings
millisecondsDisplay- : One of the strings
"auto"or"always"identifying when to display themillisecondsDisplayfield.
- : One of the strings
microseconds- : One of the strings
"long","short","narrow", or"numeric"identifying the formatting style used for themicrosecondsfield.
- : One of the strings
microsecondsDisplay- : One of the strings
"auto"or"always"identifying when to display themicrosecondsDisplayfield.
- : One of the strings
nanoseconds- : One of the strings
"long","short","narrow", or"numeric"identifying the formatting style used for thenanosecondsfield.
- : One of the strings
nanosecondsDisplay- : One of the strings
"auto"or"always"identifying when to display thenanosecondsDisplayfield.
- : One of the strings
fractionalDigits- : A number, identifying the number of fractional digits used with numeric styles.
numberingSystem- : The value provided for this property in the options argument, if present, or the value requested using the Unicode extension key
nuor filled in as a default.
- : The value provided for this property in the options argument, if present, or the value requested using the Unicode extension key
Examples
Using the resolvedOptions method
const duration = new Intl.DurationFormat("en");
const usedOptions = duration.resolvedOptions();
usedOptions.locale; // "en"
usedOptions.numberingSystem; // "latn"
usedOptions.years; // "long"
usedOptions.yearsDisplay; // "auto"
usedOptions.style; // "long"