Intl.RelativeTimeFormat.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 2020.
The resolvedOptions()
method of Intl.RelativeTimeFormat
instances returns a new object with properties reflecting the options computed during initialization of this RelativeTimeFormat
object.
Try it
Syntax
resolvedOptions()
Parameters
None.
Return value
A new object with properties reflecting the options computed during the initialization of this RelativeTimeFormat
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
nu
Unicode extension key, if requested, may be included in the output. style
-
The value provided for this property in the
options
argument, with default filled in as needed. It is either"long"
,"short"
, or"narrow"
. The default is"long"
. numeric
-
The value provided for this property in the
options
argument, with default filled in as needed. It is either"always"
or"auto"
. The default is"always"
. numberingSystem
-
The value provided for this property in the
options
argument, 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.
Examples
Using the resolvedOptions() method
const de = new Intl.RelativeTimeFormat("de-DE");
const usedOptions = de.resolvedOptions();
usedOptions.locale; // "de-DE"
usedOptions.style; // "long"
usedOptions.numeric; // "always"
usedOptions.numberingSystem; // "latn"
Specifications
Specification |
---|
ECMAScript Internationalization API Specification # sec-intl.relativetimeformat.prototype.resolvedoptions |
Browser compatibility
BCD tables only load in the browser