Skip to content

Timestamp

Displays a single moment in time as a semantic `<time>` element, either relative to now ("2 hours ago") or as an absolute date/time.

<Timestamp format="auto" value={SAMPLE} />
relative
date
time
dateTime
systemDate
systemTime
systemDateTime
<div
style={{
display: 'grid',
gap: '0.75rem',
gridTemplateColumns: 'auto 1fr',
}}>
{formats.map(format => (
<div key={format} style={{display: 'contents'}}>
<Text color="secondary" size="sm">
{format}
</Text>
<Timestamp format={format} value={SAMPLE} />
</div>
))}
</div>
<Timestamp
format="relative"
value={Temporal.Now.instant().subtract({hours: 2})}
/>
<Timestamp format="dateTime" value={SAMPLE} isTimezoneShown />
<Timestamp
format="relative"
value={Temporal.Now.instant().subtract({hours: 72})}
/>

Displays a single moment in time as a semantic `<time>` element, either relative to now ("2 hours ago") or as an absolute date/time.

PropTypeDefaultDescription
autoThresholdnumber604800 (7 days)In auto mode, the maximum age in seconds for which a relative string is shown before falling back to an absolute date/time.
classNamestringAdditional CSS class names applied to the element.
color"primary" | "secondary" | "disabled" | "inherit" | "placeholder" | "active"'secondary'Text color token. Passed through to the underlying Text.
data-testidstringTest ID applied to the element.
format"auto" | "time" | "date" | "dateTime" | "relative" | "systemDate" | "systemTime" | "systemDateTime"'auto'How to format the timestamp.
hasTooltipbooleantrueWhether to show a tooltip with the full absolute date/time on hover. Only applies while the visible text is relative.
isTimezoneShownbooleanfalseWhether to append the timezone abbreviation to absolute (non-system) formats.
refRef<HTMLTimeElement>Ref forwarded to the <time> element.
size"sm" | "md" | "lg" | "inherit" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl"Font size token. Passed through to the underlying Text.
styleCSSPropertiesInline styles applied to the element.
type"body" | "code" | "label" | "large" | "supporting" | "inherit" | "display-1" | "display-2" | "display-3"'supporting'Typographic preset. Passed through to the underlying Text.
value*TimestampValueThe moment to display. Accepts a Temporal.Instant or ZonedDateTime, a Unix epoch timestamp in **seconds**, or an ISO 8601 string.
weight"medium" | "inherit" | "normal" | "semibold" | "bold"Font weight. Passed through to the underlying Text.