Skip to main content

Relative Time

shadow

The RelativeTime component is an element used to display the relative time based on the inserted date. Calculates and displays the relative time difference between the current date and the specified date. The relative time format is localized based on the language of the user's browser.

Basic usage

Attributes and Properties

date

DescriptionSets the date of the relative time component.
Attributedate
Typestring
Defaultundefined

window

DescriptionSets the language of the relative time component.
Attributewindow
Typestring
Defaultundefined

Events

No events available for this component.

Methods

getRelativeTimeString

DescriptionReturns the relative time string for the specified date.
SignaturegetRelativeTimeString(lang = navigator.language) => string

isISODate

DescriptionChecks if the string is in ISO date format.
SignatureisISODate(str) => boolean

CSS Shadow Parts

NameDescription
nativeRefers to div inside an element.

CSS Custom Properties

No CSS custom properties available for this component.

Slots

No slots available for this component.