Components
← All components

Relative Time

stimeo--relative-time

Renders a timestamp as "3 minutes ago" and keeps it fresh, via Intl.

The stimeo--relative-time controller follows the HTML <time> semantics. It computes the difference from the datetime attribute to now and formats it with Intl.RelativeTimeFormat — a browser standard, no added dependency. The polling interval widens as the timestamp ages (seconds → minutes → hours → days), and past a threshold it falls back to the authored absolute text (data-state="absolute"). The machine-readable datetime is left untouched while only the visible text updates, and the element is intentionally not a live region, so updates never interrupt a screen reader. The polling timer is torn down on disconnect (Turbo included). Behavior only — styling is owned by this Playground.

running
  • Posted
  • Updated
  • Due
  • Archived

The text refreshes on its own as time passes (the interval widens as the stamp ages). Items within a few minutes update about once a minute, so if you keep this page open the first “Posted” will tick to “4 minutes ago”, “5 minutes ago”, and so on. Updates are silent, to avoid interrupting screen readers. Hover any time to see its absolute value.