Changelog Azalea Kit UI 101 Usage Customizing Utilities Form controls Laravel Vue FHIR Types Accessibility Icons Actions Button Button group Layout and structure Card Card section Care summary Care timeline Divider Empty state Footer Header Layout Stack Table Selection and input Calendar Checkbox Checkbox group Color picker Combobox Combobox option Input Input mask Memorable date Number input Option Phone input Radio Radio button Radio group Range Select SSN input Tag Textarea Toggle ZIP code input Images and icons Avatar Icon Icon button Logo Feedback indicators Badge Banner Progress bar Skeleton Skeleton body text Skeleton display text Skeleton thumbnail Spinner Typography Text Navigation Breadcrumb Breadcrumb item Dropdown Menu Menu item Menu label Navigation Nav group Nav item Nav toggle Pagination Tab Tab group Tab panel Top bar Tree Tree item User menu Overlays Dialog Popover Tooltip Utilities Collapsible FHIR address FHIR human name FHIR quantity FHIR questionnaire Format bytes Format date Format number Relative time Resize observer Split panel Tooltip Border Color Shadow Spacing Transition Typography Z-index Contributing Visual Tests Light Dark System

Relative Time

<ahi-relative-time> | AhiRelativeTime

Displays the difference between a date and the current time. Localization is handled by the browser’s Intl.RelativeTimeFormat API. No language packs are required.

Used to display the time difference between a given date & time and now.

Time since 2018:
Time since 2018: <ahi-relative-time date="2018-12-31T23:59:59Z"></ahi-relative-time>

Examples

Keeping up to date

Use the sync property to keep the relative time updated with the current time.

Time since page load ():
Time since page load (<ahi-format-date hour="numeric" minutes="2-digit" hour-format="auto"></ahi-format-date>):
<ahi-relative-time sync></ahi-relative-time>

Importing

Script Bundler

To import this component using a script tag:

<script type="module" src="/path/to/azalea-kit-ui/dist/components/relative-time/relative-time.js"></script>

To import this component using a bundler:

import '@azaleahealth/azalea-kit-ui/dist/components/relative-time/relative-time.js';

Properties

Name Description Type Default
date The date/time to format. If not set, the current date and time will be used. When passing a string, it’s strongly recommended to use the ISO 8601 format to ensure timezones are handled correctly. To convert a date to this format in JavaScript, use date.toISOString(). Date | string new Date()
format The length of the internationalized message. Defaults to ‘long’. 'long' | 'short' | 'narrow' 'long'
numeric The format of output message. Defaults to ‘auto’. 'always' | 'auto' 'auto'
sync Keeps the relative time updated with the current time. boolean false
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about properties and attributes.