309

Time

Displays a specific time (or datetime).

import { Time } from "@/components/ui/time";

export function TimeDemo() {

Installation

pnpm dlx shadcn@latest add junwen-k/ui-x/time

Usage

import { Time } from "@/components/ui/time";
<Time />

Examples

Default

import { Time } from "@/components/ui/time";

export function TimeDemo() {

Format

import { Time } from "@/components/ui/time";

export function TimeFormat() {

API Reference

Time

Renders a semantic <time> element with a machine-readable dateTime attribute, formatting both with date-fns format.

PropTypeDefaultDescription
childrenDate | string | number-The date to display. Required.
formatStrstring"PPP"The date-fns format for the visible text.
dateTimeFormatStrstring"yyyy-MM-dd"The date-fns format for the dateTime attribute.
...propsReact.ComponentProps<"time">-Props spread to the <time> element.