Standard built-ins

Intl.RelativeTimeFormat.prototype.format()

Try the free JavaScript compiler

Return localized relative-time string from a signed quantity and unit.

Formal Syntax & Structure

javascript syntaxjavascript
formatter.format(value, unit)

Parameters & Attributes

NameTypeDescription
valueNumberSigned quantity.
unitStringSupported 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"));
JavaScript Reference