RelativeTime
RelativeTime displays time in a way that is clear, concise, and accessible.
Page navigation navigation
This component's features all come from the relative-time-element (GitHub staff only) custom element.
React examples
Default
With time
With leading zeros
Without "on" prefix
Micro format
Without a title attribute
As a link with a tooltip
Props
RelativeTime
| Name | Default | Description | 
|---|---|---|
| datetime Required | stringAn ISO8601 time representing the time | |
| date  | stringInstead of passing the  | |
| format  | 'auto' | 'auto' | 'micro' | 'elapsed'The format with which to display the time | 
| tense  | 'auto' | 'auto' | 'past' | 'future'The tense to use when displaying a relative time | 
| precision  | 'second' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'The precision to use when displaying an elapsed time | 
| threshold  | 'P30D' | stringThe threshold (ISO8601 duration) to display relative dates within | 
| prefix  | 'on' | stringThe prefix to use when displaying a localised (non relative) date | 
| second  | 'numeric' | '2-digit'The format with which to render seconds | |
| minute  | 'numeric' | '2-digit'The format with which to render minutes | |
| hour  | 'numeric' | '2-digit'The format with which to render hours | |
| weekday  | 'short' | 'long' | 'narrow'The format with which to render weekdays | |
| day  | 'numeric' | '2-digit'The format with which to render days | |
| month  | 'numeric' | 'numeric' | '2-digit' | 'short' | 'long' | 'narrow'The format with which to render months | 
| year  | 'numeric' | '2-digit'The format with which to render years | |
| timeZoneName  | 'long' | 'short' | 'shortOffset' | 'longOffset' | 'shortGeneric' | 'longGeneric'The format with which to render the time zone | |
| ref  | React.RefObject<RelativeTimeElement> | |
| noTitle  | booleanRemoves the  | |
| attributeChangedCallback  | (attrName: string, oldValue: unknown, newValue: unknown) => void | |
| connectedCallback  | () => void | |
| onRelativeTimeUpdated  | null | (event: RelativeTimeUpdatedEvent) => void | |
| update  | () => void | |
| as  | "relative-time" | React.ElementType | 
| sx Deprecated | SystemStyleObject |