relative-time
Outputs a localized time phrase relative to the current date and time. Localization is handled by the browserβs Intl.RelativeTimeFormat API β no language packs required.
Usage
relative-time(date="2026-04-29T10:00:00Z")Attributes
| Name | Type | Default | Description |
|---|---|---|---|
date | string | Date | new Date() | ISO 8601 date string to calculate from. |
format | long | short | narrow | long | Display style. |
numeric | auto | always | auto | auto shows βyesterdayβ; always shows β1 day agoβ. |
lang | string | browser default | BCP 47 language tag (e.g. en-US, de, zh-CN). |
sync | boolean | false | Auto-updates as time passes. |
Dates must be ISO 8601. Avoid ambiguous formats like
03/04/2026β always useYYYY-MM-DDTHH:MM:SSZ.