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

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"

Syntax

js
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

js
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® 2027 Internationalization API Specification
# sec-intl.relativetimeformat.prototype.resolvedoptions

Browser compatibility

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
Chrome – Full support
Chrome 71 (Release date: 2018-12-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 65 (Release date: 2019-01-29)
footnote Full support
Opera – Full support
Opera 58 (Release date: 2019-01-23)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 71 (Release date: 2018-12-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 65 (Release date: 2019-01-29)
footnote Full support
Opera Android – Full support
Opera Android 50 (Release date: 2019-02-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 71 (Release date: 2018-12-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1.8 (Release date: 2021-03-02)
footnote Full support
Node.js – Full support
Node.js 12 (Release date: 2019-04-23)
footnote
footnote Before version 13.0.0, only the locale data for en-US is available by default. See the RelativeTimeFormat() constructor for more details.

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

See also