Skip to content
Nana UI

Relative Time

Renders a localised, auto-updating relative timestamp — “2 hours ago”, “in 3 days” — from a date. It refreshes itself on a cadence proportional to the elapsed time (every second under a minute, every minute under an hour, and so on) and outputs a semantic <time> element carrying the machine readable datetime plus an absolute title for accessibility.

Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/relative-time";
<nana-relative-time date="2026-01-01T00:00:00Z"></nana-relative-time>
PropertyTypeDefaultDescription
dateDate | string | numbernew Date()The date — a Date, an ISO string, or a timestamp
format'long' | 'short' | 'narrow''long'Wording length passed to Intl.RelativeTimeFormat
localestring | undefinedBCP 47 locale (defaults to the document locale)
livebooleantrueKeep the value refreshing as time passes
Explore Relative Time interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook