Skip to content
HomeCobalt

Relative time

Says when something happened the way people say it, "5 minutes ago" or "yesterday", and from seven days on gives the date, with the full date and time on hover.

Examples

Times from a minute to a month ago; hover one for the full date.
  • Comment from Jo Park
  • Booking changed
  • Payment received
  • Booking made
  • Account opened
In an itemThe time at the end of a list row, in the row's small muted figures.
Harbour Large Cap Core
Filed a 13F
Calder Global Equity
Amended its Form ADV

States

  • Filed
  • First filed
AbsoluteFrom seven days on it is the date, with the year when it is not this year.

Filed

FrozenWith now passed, the text counts from that moment and never ticks, as a test or a screenshot needs.

Saved

RelativeUnder a week it is words, and it keeps itself current, so "now" becomes "1 minute ago" as you watch.
  • Holdings last syncedUnknown
UnknownA timestamp that is not a date, as an import can leave it, reads Unknown in the time's own place.

Usage

Use it when

  • A row, a comment or an event shows when it happened, and recent times matter more than exact ones.
  • A status line says when something was last saved or synced.

Use something else when

  • The exact date is the fact, such as a filing date in a table or a due date. Use DataList instead, with the date from date() in @/lib/cobalt/format.
  • The time is in the future and the hour matters, such as a check-in. Use Table instead, or a plain time with the date and hour.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/relative-time.json
import { RelativeTime } from "@/components/cobalt/ui/relative-time"