Time
Renders a date, a date and time, or a relative time from a
DateTime
.
Date
The default shows the date alone.
<.time time={~U[2026-10-01 09:30:00Z]} />
Date and time
show_time
adds the time of day with seconds.
<.time time={~U[2026-10-01 09:30:00Z]} show_time />
Relative
relative
shows the distance from now. Hover it to see the full date.
1 month ago
October 1, 2026
<.time time={~U[2026-10-01 09:30:00Z]} relative />
Relative with time
With both, the tooltip includes the time of day.
1 month ago
October 1, 2026, at 9:30:00 AM
<.time time={~U[2026-10-01 09:30:00Z]} relative show_time />
Guidelines
-
Pass a
DateTime. The component callsDateTime.to_iso8601/1on it, so aNaiveDateTimeraises. - The value is formatted in the time zone it carries and without a zone label. Convert it before rendering if the reader expects another zone.
-
Show the date alone by default. Add
show_timewhen the exact moment matters, such as for a build start. -
Use
relativefor recent activity, such as the last run of a test. The full date appears in a tooltip on hover. -
Inside tables, use the table's
time_cell, which takes the same attributes.
API reference
<.time>
| Attribute | Type | Default | Description |
|---|---|---|---|
|
relative
|
boolean
|
false
|
Whether to show the time relative to now.
|
|
show_time
|
boolean
|
false
|
Whether to show the time or date only.
|
|
time
Required
|
DateTime
|
–
|
The time to render.
|