coderef

Intl.RelativeTimeFormatBaseline · Widely available

The Intl.RelativeTimeFormat API creates a locale-aware formatter that turns an object representing a relative time (such as '1 day ago') into a localized string.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Sep 16, 2020. Widely available since Mar 16, 2023.

Browser support

DesktopChrome
1–70Not supported
71+Supportedsince Dec 4, 2018
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–75Not supported
76+Supportedsince May 5, 2020
Current: 157
Safari
1–13.1Not supported
14+Supportedsince Sep 16, 2020
Current: 27
MobileChrome Android
18–70Not supported
71+Supportedsince Dec 4, 2018
Current: 155
Firefox Android
4–68Not supported
79+Supportedsince Jul 28, 2020
Current: 157
Safari iOS
1–13.4Not supported
14+Supportedsince Sep 16, 2020
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: RelativeTimeFormat.

Feature detection

JS · check before using
if ("RelativeTimeFormat" in Intl || ("prototype" in Intl && "RelativeTimeFormat" in Intl.prototype)) {
  // Intl.RelativeTimeFormat is available
}

Sub-features

Support for each part of the feature (10). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Intl.RelativeTimeFormat71796514716514
Intl.RelativeTimeFormat.RelativeTimeFormat71796514716514
Intl.RelativeTimeFormat.RelativeTimeFormat.locales_parameter71796514716514
Intl.RelativeTimeFormat.RelativeTimeFormat.options_parameter.options_localeMatcher_parameter71796514716514
Intl.RelativeTimeFormat.RelativeTimeFormat.options_parameter.options_numberingSystem_parameter71797614717914
Intl.RelativeTimeFormat.RelativeTimeFormat.options_parameter.options_numeric_parameter71796514716514
Intl.RelativeTimeFormat.format71796514716514
Intl.RelativeTimeFormat.formatToParts71797014717914
Intl.RelativeTimeFormat.resolvedOptions71796514716514
Intl.RelativeTimeFormat.supportedLocalesOf71796514716514