This page as markdown: /relative-time.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

RelativeTime

Status: stable

A human relative timestamp (e.g. "3 minutes ago") that reveals the full absolute date/time on hover or focus. Renders a native

Keywords: relative time, timestamp, time ago, date

Usage

Use RelativeTime to show recent activity or timestamps in conversational relative language.

Best practices

Props

Name Type Default Description
date Date | string | number — The instant to render. Accepts a Date, an ISO/parseable string, or an epoch number (ms). Coerced to a Date for date-fns. A value that does not parse renders as its own text, with no tooltip and no dateTime, instead of throwing.
now Date | number Date.now() The instant "ago" is measured from. Pass the same value on the server and the client so both render the same words and the page hydrates cleanly; leave it out to measure from the reader's clock.
locale Locale (date-fns) en-US A date-fns locale for the relative words and the absolute time in the tooltip (import { fr } from "date-fns/locale").
className string — Merged onto the
...time props Omit<ComponentPropsWithRef<"time">, "dateTime" | "children"> — Remaining native

Tokens used

popover, popover-foreground, border, ring

Motion

Accessibility

Related

Examples

Basic

import { RelativeTime, TooltipProvider } from "@sableui/react"

<TooltipProvider><RelativeTime date={new Date()} /></TooltipProvider>

From an ISO string

import { RelativeTime, TooltipProvider } from "@sableui/react"

<TooltipProvider><RelativeTime date="2025-04-29T16:05:12Z" /></TooltipProvider>

Server-rendered, measured from the request

import { RelativeTime, TooltipProvider } from "@sableui/react"

<TooltipProvider><RelativeTime date={post.createdAt} now={requestTime} /></TooltipProvider>