RelativeTime
Time & Keyboard

RelativeTime

Relative timestamp that re-renders as the clock moves (for example "2m ago"), for log tables, activity feeds, and comment threads.

Props

RelativeTimeProps props
PropTypeDefaultDescription
dateDate—The instant to display relative to now.
formatRelativeStyle"narrow""narrow" | "short" | "long". Narrow is the log-table format (3m); long renders as prose.
livebooleantrueStop re-rendering as the clock moves. Disable for static snapshots.
showTitlebooleantrueShow the absolute timestamp on hover via the title attribute.
cutoffMsnumber—Past this age in milliseconds, show the absolute date instead of a relative string.

Examples

All formats

RelativeTime formats

Future date

Future date

Past dates at different intervals

Various past intervals
ImportTSX
import { RelativeTime } from "@solarius/onset";
import type { RelativeTimeProps, RelativeStyle } from "@solarius/onset";