Standard built-ins
Intl.RelativeTimeFormat.prototype.format()
Return localized relative-time string from a signed quantity and unit.
Formal Syntax & Structure
javascript syntaxjavascript
formatter.format(value, unit)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| value | Number | Signed quantity. |
| unit | String | Supported temporal unit, e.g. day or hour. |
Return Value
String
Localized phrase.
Working Example
Example Snippetjavascript
console.log(new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(0,"day"));