function relativeTime
relativeTime(date: Date): string

Returns how long ago date was, as "3 minutes ago", in the current locale. It is computed at render, so the text only moves on when the caller re-renders. A month counts 30 days and a year 365. Every date shown is of something that happened, so one in the future, which only a clock ahead of this one can give, reads as "now".

Parameters

date: Date

Return Type

string

Usage

import { relativeTime } from "src/utils/shared/relativeTime.ts";