Calm motion: animations on this site only fade, with no movement
RelativeTime
Time ago, in your language, kept up to date
A date as "3 hours ago" or "in 2 days", in the language of the reader. Use it in feeds, comments, and lists, where how long ago matters more than the exact date. For a date that people must read exactly, such as a due date in a contract, show the date.
Basic
- Posted
- Edited
- Replied
- Due
- In German
- Short
- Live, counted from the time now (hover for the full date):
valueis aDate, a timestamp in ms, or a date string. The element is a<time>with the exactdatetime, so machines and screen readers can read the date. The tooltip shows the full date and time in the time zone of the reader.- The unit follows the distance: seconds, minutes, hours, days, months, years.
numeric="auto"(default) writes "yesterday" and "now".numeric="always"writes "1 day ago".formatislong,short, ornarrow. The name is notstyle, because Vue reserves that one. localesets the language. The words come fromIntl.RelativeTimeFormat, so there is nothing to translate by hand. Withoutlocale, the text is English.- With
live(default), the text updates while the page is open. It checks every 5 seconds for a fresh time, and less often for older ones. Turn it off with:live="false". The text is not a live region, so a screen reader does not announce each change. - The server and the browser disagree on the time now and on the time zone. So the server writes a plain date in UTC ("Oct 9, 2026"), and the relative text appears after mount. A fixed
nowis the same on both sides, so the relative text shows at once. Usenowfor tests and for a page that you render ahead of time. - An invalid
valuerenders nothing.
Usage
ts
import { BlessRelativeTime } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
value* | string | number | Date | — | a Date, a timestamp in ms, or a date string |
locale | string | — | language of the words, for example `de`. Default: English until you choose. |
numeric | "always" | "auto" | "auto" | `auto` writes "yesterday" and "now". `always` writes "1 day ago". |
format | "long" | "short" | "narrow" | "long" | `long` ("2 hours ago"), `short` ("2 hr. ago"), or `narrow` |
live | boolean | true | keep the text up to date while the page is open |
now | number | Date | — | the moment to count from. Default: the time now. Pass one for a fixed result. |