dentil

Date

Date formats one instant in a time zone you pass as timezone. The same timestamp reads as London, New York or Tokyo time. showTimezone underlines the date. Hover one to see that zone beside UTC.

@dentil/date
On this page
London
New York
Tokyo

Installation

pnpm dlx shadcn@latest add @dentil/date
npx shadcn@latest add @dentil/date
yarn dlx shadcn@latest add @dentil/date
bunx --bun shadcn@latest add @dentil/date

Files land in components/dentil/date/. It uses Intl.DateTimeFormat and the stock Popover and HoverCard. Pass an IANA name such as Europe/London. There is no provider.

Usage

import { Date } from '@/components/dentil/date/date';

// 7 Nov 2026, 09:14 UTC. Unix seconds, milliseconds, an ISO string or a Date all work.
const created = 1_794_042_840;

<Date date={created} timezone="Europe/London" />
<Date date={created} timezone="America/New_York" showTimezone hover side="top" align="end" />
<Date date={created} timezone="Europe/London" showTime={false} showYear />

The year is omitted when the date is in the current year in timezone. showYear puts it back. The popover always shows the clock time, including when the date itself hides it. hover opens it on hover and keeps it open while the pointer is over the popover. side and align set where it opens. formatDate and toDate live in components/dentil/date/format, so a server component can call them without pulling in the client component. formatDate appends the short zone name when showTimezone is set, instead of opening a popover.

Examples

Format

Turn the time off for a date, or pass a past year and the year appears on its own. An empty value renders fallback.

This year
Date only
Another year
Forced year
Missing—

API reference

Date

PropTypeDefaultDescription
datenumber | string | Date | null | undefined—Unix seconds, unix milliseconds, an ISO string or a Date. Anything above 1e11 is treated as milliseconds. Empty or invalid values render fallback.
timezonestring—IANA time zone the value is formatted in, such as Europe/London. Omit it to use the runtime zone, which can differ between server and client. An unknown name is formatted as UTC.
localestring—BCP 47 language tag passed to Intl.DateTimeFormat. Omit it to use the runtime locale.
showTimebooleantrueInclude the time in 24-hour form, such as 09:14.
showYearbooleanfalseInclude the year even when the date falls in the current year in timezone.
showTimezonebooleanfalseUnderlines the date and opens a popover with the time in timezone and the same instant in UTC. Click it, or hover when hover is set.
hoverbooleanfalseOpens the popover while the pointer is over the date or the popover. Clicking and the keyboard still open it. Ignored unless showTimezone is set.
side'top' | 'right' | 'bottom' | 'left''bottom'Side of the date the popover opens on.
align'start' | 'center' | 'end''start'Alignment of the popover along that side.
fallbackReactNodenullRendered when date is null, undefined, an empty string or invalid.
classNamestring—Merged onto the date. With showTimezone, that is the button that opens the popover.
…propsOmit<ComponentProps<'time'>, 'dateTime' | 'children'>—Other props are passed to the time element. dateTime is the UTC ISO string.

formatDate

formatDate(value, options) from @/components/dentil/date/format returns the compact string, or null. With showTimezone it appends the short zone name.

PropTypeDefaultDescription
valuenumber | string | Date | null | undefined—Same values as the date prop. Returns null when the value cannot be parsed.
timezonestring—IANA time zone. Omit it to use the runtime zone. An unknown name is formatted as UTC.
localestring—BCP 47 language tag. Omit it to use the runtime locale.
showTimebooleantrueInclude the 24-hour time.
showYearbooleanfalseInclude the year even when the date is in the current year.
showTimezonebooleanfalseAppend the short zone name to the returned string.

toDate

toDate(value) returns a Date or null.

PropTypeDefaultDescription
valuenumber | string | Date | null | undefined—Unix seconds, unix milliseconds, an ISO string or a Date. Returns null for empty or invalid values.