Format the absolute distance from a date to now in concise English words.
Usage:
import { formatDistanceToNow } from "mazey";const ret = formatDistanceToNow(new Date(Date.now() - 60 * 60 * 1000));console.log(ret); Copy
import { formatDistanceToNow } from "mazey";const ret = formatDistanceToNow(new Date(Date.now() - 60 * 60 * 1000));console.log(ret);
Output:
about 1 hour Copy
about 1 hour
A Date, millisecond timestamp, or string accepted by isValidDate.
Date
isValidDate
The absolute approximate distance phrase, or an empty string for invalid input.
Past and future dates use the same wording without ago or in. Months and years use fixed approximate durations of 30 and 365 days.
ago
in
Format the absolute distance from a date to now in concise English words.
Usage:
Output: