Standard built-ins
Intl.RelativeTimeFormat
Format signed quantities in temporal units; does not calculate the quantity.
Formal Syntax & Structure
javascript syntaxjavascript
new Intl.RelativeTimeFormat([locales], [options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| locales | String | Array | Requested locale tag or prioritized locale list. |
| options | Object | Formatting options. |
Return Value
Intl.RelativeTimeFormat
New formatter.
Working Example
Example Snippetjavascript
console.log(new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(-1,"day"));