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.
const rtf1 = new Intl.RelativeTimeFormat("en", { style: "narrow" });
const options1 = rtf1.resolvedOptions();
const rtf2 = new Intl.RelativeTimeFormat("es", { numeric: "auto" });
const options2 = rtf2.resolvedOptions();
console.log(`${options1.locale}, ${options1.style}, ${options1.numeric}`);
// Expected output: "en, narrow, always"
console.log(`${options2.locale}, ${options2.style}, ${options2.numeric}`);
// Expected output: "es, long, auto"
resolvedOptions()
None.
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:
localeThe 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.
styleThe 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".
numericThe 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".
numberingSystemThe 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.
const de = new Intl.RelativeTimeFormat("de-DE");
const usedOptions = de.resolvedOptions();
usedOptions.locale; // "de-DE"
usedOptions.style; // "long"
usedOptions.numeric; // "always"
usedOptions.numberingSystem; // "latn"
| Desktop | Mobile | Server | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | Bun | Deno | Node.js | |
resolvedOptions |
71 | 79 | 65 | 58 | 14 | 71 | 65 | 50 | 14 | 10.0 | 71 | 14 | 1.0.0 | 1.8 | 12.0.0Before version 13.0.0, only the locale data foren-US is available by default. See the RelativeTimeFormat() constructor for more details. |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/resolvedOptions