Intl.DurationFormat.prototype.resolvedOptions()
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
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
js
resolvedOptions()
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. style-
One of the strings
"long","short","narrow", or"digital"identifying the duration formatting style used. years-
One of the strings
"long","short", or"narrow"identifying the formatting style used for theyearsfield. yearsDisplay-
One of the strings
"auto"or"always"identifying when to display theyearsfield. months-
One of the strings
"long","short",and "narrow"identifying the formatting style used for themonthsfield. monthsDisplay-
One of the strings
"auto"or"always"identifying when to display themonthsfield. weeks-
One of the strings
"long","short",and "narrow"identifying the formatting style used for theweeksfield. weeksDisplay-
One of the strings
"auto"or"always"identifying when to display theweeksfield. days-
One of the strings
"long","short", and"narrow"identifying the formatting style used for thedaysfield. daysDisplay-
One of the strings
"auto"or"always"identifying when to display thedaysfield. hours-
One of the strings
"long","short","narrow","2-digit", or"numeric"identifying the formatting style used for thehoursfield. hoursDisplay-
One of the strings
"auto"or"always"identifying when to display thehoursfield. minutes-
One of the strings
"long","short","narrow","2-digit", or"numeric"identifying the formatting style used for theminutesfield. minutesDisplay-
One of the strings
"auto"or"always"identifying when to display theminutesfield. seconds-
One of the strings
"long","short","narrow","2-digit", or"numeric"identifying the formatting style used for thesecondsfield. secondsDisplay-
One of the strings
"auto"or"always"identifying when to display thesecondsfield. milliseconds-
One of the strings
"long","short","narrow", or"numeric"identifying the formatting style used for themillisecondsfield. millisecondsDisplay-
One of the strings
"auto"or"always"identifying when to display themillisecondsDisplayfield. microseconds-
One of the strings
"long","short","narrow", or"numeric"identifying the formatting style used for themicrosecondsfield. microsecondsDisplay-
One of the strings
"auto"or"always"identifying when to display themicrosecondsDisplayfield. nanoseconds-
One of the strings
"long","short","narrow", or"numeric"identifying the formatting style used for thenanosecondsfield. nanosecondsDisplay-
One of the strings
"auto"or"always"identifying when to display thenanosecondsDisplayfield. 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.
Examples
Using the resolvedOptions method
js
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"
Specifications
| Specification |
|---|
| Intl.DurationFormat # sec-Intl.DurationFormat.prototype.resolvedOptions |
Browser compatibility
BCD tables only load in the browser