Import the plugin once to add formatRelative() to core moments and calendar dates. Phrases come from Intl.RelativeTimeFormat with natural wording enabled, producing yesterday, today, and tomorrow alongside counted units.
Formats the distance from a reference point to this value. Omitting the reference compares a moment against now() in its own zone and a calendar date against today().
Parameters
toDateTimeInput | CalendarDateInput
Reference moment or date to measure from, defaulting to now or today.
localestring
BCP 47 locale tag overriding the configured default for this call.
Standalone helpers exported when formatting a precomputed offset in seconds or calendar days. Negative numbers read in the past and positive numbers read in the future.
Parameters
secondsnumberrequired
Signed offset in seconds for relativeSeconds(), or whole days for relativeDays().
localestring
BCP 47 locale tag overriding the configured default.
Returns
string
Localized relative time phrase using the same thresholds as formatRelative().