Relative Time

“5 minutes ago”, “in 3 days”: a date described relative to now, kept up to date while the page is open.

Last deploy

Installation#

pnpm dlx shadcn@latest add @balick/relative-time

Or pass the full URL: https://ui.balick.me/r/relative-time.json

Usage#

import { RelativeTime } from "@/components/ui/relative-time"

export function Published({ date }: { date: string }) {
  return <RelativeTime date={date} />
}

Props#

PropTypeDefault
date

The moment to describe. Required.

Date | string | number—
locale

Language of the text, as a BCP 47 tag such as "fr".

string"en"