Skip to Content
ComponentsTimeago

Timeago

Relative or formatted timestamp. In isDuration mode it updates live via a setInterval. Accepts Date, ISO string, or numeric timestamp.

Preview

Usage

import { Timeago } from '@wire-ui/react' // Live relative time ("5 minutes ago", "2 hours ago", "Just now") <Timeago datetime={new Date()} isDuration /> // Formatted date ("Today, 09:00" / "15 Jun 2025, 09:00") <Timeago datetime="2025-06-15T09:00:00" /> // Time only ("09:00") <Timeago datetime={new Date()} timeOnly />

Props

PropTypeDefaultDescription
datetimeDate | string | numberrequiredThe timestamp to display
isDurationbooleanfalseShow relative time (“5 minutes ago”); updates live
timeOnlybooleanfalseShow only the time portion (“09:00”)
classNamestringApplied to the <time> element

Live updates

In isDuration mode, the component sets a setInterval that recalculates the displayed string every minute. The datetime attribute on the <time> element always holds the original ISO timestamp for machine readability.

Last updated on

MIT License © 2026 wire-ui