Relative Time

A component that displays time in various timezones.

Installation

npx love-ui@latest add relative-time

Usage

import { RelativeTime, RelativeTimeZone, RelativeTimeZoneLabel, RelativeTimeZoneDisplay, RelativeTimeZoneDate } from "@/components/relative-time"
<RelativeTime>
  <RelativeTimeZone timezone="America/Los_Angeles">
    <RelativeTimeZoneLabel>Los Angeles</RelativeTimeZoneLabel>
    <RelativeTimeZoneDisplay />
    <RelativeTimeZoneDate />
  </RelativeTimeZone>
  <RelativeTimeZone timezone="America/New_York">
    <RelativeTimeZoneLabel>New York</RelativeTimeZoneLabel>
    <RelativeTimeZoneDisplay />
    <RelativeTimeZoneDate />
  </RelativeTimeZone>
</RelativeTime>

Features

  • Displays multiple timezones simultaneously
  • Supports both controlled and uncontrolled time states
  • Auto-updates every second when no time is provided
  • Customizable date and time format options
  • Clean, minimal UI with timezone labels and formatted times
  • Responsive layout with flex positioning

Examples

Custom date format

Custom time format

Controlled time