Options
style
The style
option determines the format of the relative time. Possible values:
"long"
(default): e.g., "in 1 month""short"
: e.g., "in 1 mo.""narrow"
: e.g., "in 1 mo." (may resemble the short style in some locales)
Examples:
numeric
Whether to include numeric values in the output. "always"
(default) uses numbers like "1 day ago". "auto"
allows phrases like "yesterday".
Examples:
stops
Defines the granularity for the relative time. Accepts an array of stops: "year"
, "quarter"
, "month"
, "week"
, "day"
, "hour"
, "minute"
, "second"
. Default: ["year", "month", "week", "day", "hour", "minute"]
.
NOTE
This option is not part of Intl.RelativeTimeFormat
API.
Examples:
Formatter options used in this example
typescript
{
numeric: 'auto';
}
"Attributions and copyright licensing" by Mozilla Contributors, licensed under CC-BY-SA 4.0.