RelativeTime

Displays a date as a localized phrase relative to now, auto-updating

Category: display · WCAG 2.2-AA · time, date, relative, i18n, display

States

Props

PropTypeDefaultDescription
dateDate | number | stringThe date to render relative to now.
syncbooleantrueWhen true, updates the relative time as it elapses.
nownumberOverride "now" (ms); disables the interval. Pass a serialized server timestamp under SSR for a byte-deterministic render.
formatIntl.RelativeTimeFormatOptionsIntl.RelativeTimeFormat options controlling the output.

When to use

When not to use

How to build an accessible RelativeTime in React →

Examples

Basic

<RelativeTime date={post.createdAt} />

Natural language

<RelativeTime date={date} format={{ numeric: "auto" }} />

Static (no ticking)

<RelativeTime date={date} sync={false} />

SSR deterministic

Relative text is clock-dependent, so it is hydration-safe by default (the server text is kept and corrected on the client). Pass a serialized server timestamp via `now` when you need identical server/client output with no post-hydration correction.

<RelativeTime date={date} now={serverNow} />

Related components

← Back to docs