Relative Time Formatter

Turn dates into “3 days ago” in any language.

Runs locallyYour input is processed in this tab. The editor blocks outgoing network requests.

The Relative Time Formatter turns a date into phrases like "3 days ago", "yesterday" or "in 3 months" in any language, using the browser's Intl.RelativeTimeFormat. It chooses a fitting unit automatically, shows a breakdown in every unit, and the code to produce the same text in your app. Everything runs in your browser — nothing is uploaded.

How to format a date as "time ago"

  1. Enter a date or timestamp — 2026-09-23T10:00:00Z, 2026-12-25, 26 Sep 2026 14:05 or an epoch value. It is compared with the current time.
  2. Pick a locale such as en, hi, de or ja, and choose whether to allow words like "yesterday" (auto) or always use numbers (always).
  3. Copy the phrase, or pick another unit from the breakdown. Format this date opens the same date in the Date Formatter for an absolute form to show alongside it.

Examples

Relative time depends on the moment you look, so these results are fixed to a reference time of 26 Sep 2026, 10:00 UTC. Your results will reflect the actual current time.

Past and future in English

Date (UTC) numeric: auto numeric: always
2026-09-26 09:59:30 30 seconds ago 30 seconds ago
2026-09-26 07:00 3 hours ago 3 hours ago
2026-09-25 10:00 yesterday 1 day ago
2026-09-23 10:00 3 days ago 3 days ago
2026-09-27 10:00 tomorrow in 1 day
2026-08-28 10:00 4 weeks ago 4 weeks ago
2026-12-25 00:00 in 3 months in 3 months
2025-09-26 10:00 last year 1 year ago

The same dates in other languages

Grammar, word order and plural forms come from the browser's locale data:

Date (UTC) hi de es ja fr
2026-09-23 3 दिन पहले vor 3 Tagen hace 3 días 3 日前 il y a 3 jours
2026-09-25 कल gestern ayer 昨日 hier
2026-09-27 कल morgen mañana 明日 demain
2026-12-25 3 माह में in 3 Monaten dentro de 3 meses 3 か月後 dans 3 mois

Note that Hindi uses the same word, कल, for both yesterday and tomorrow; context decides the meaning.

Every unit for one date

The breakdown for 2026-09-23 10:00 UTC (three days before the reference time):

Text
unit     auto                 always               narrow
year     this year            0 years ago          0y ago
quarter  this quarter         0 quarters ago       0q ago
month    this month           0 months ago         0mo ago
week     this week            0 weeks ago          0w ago
day      3 days ago           3 days ago           3d ago
hour     72 hours ago         72 hours ago         72h ago
minute   4,320 minutes ago    4,320 minutes ago    4,320m ago
second   259,200 seconds ago  259,200 seconds ago  259,200s ago

Options explained

The Relative Time Formatter is a form-style workbench, so it has no registry settings. These are its controls:

  • Date — any form the Date Formatter accepts: ISO 8601, RFC 2822, SQL DATETIME, 26 Sep 2026, or Unix seconds and milliseconds. A value without an offset is read in your browser's time zone.
  • Locale — a BCP 47 language tag such as en, en-IN, hi, de, pt-BR or ja.
  • Numeric — auto allows phrases like "yesterday", "tomorrow", "last year" and "this week"; always forces a number, as in "1 day ago".
  • Unit breakdown — the same difference in every unit, in auto, always and narrow styles, for when a fixed unit suits your interface better than the automatic choice.

Common relative time problems

"yesterday" appears for something 30 hours ago

Days are counted as 24-hour blocks from now and rounded, not by calendar date. 30 hours rounds to 1 day, which auto renders as "yesterday". If calendar days matter — "yesterday at 23:00" — compare dates in the user's time zone yourself.

"in 0 years" or "this year" in the breakdown

Units larger than the difference round to zero. auto turns zero into "this year" or "this week"; always shows "0 years ago". Use the automatic phrase at the top, or choose a smaller unit.

The phrase shifts by an hour

A date without an offset, such as 2026-09-26 14:05, is read in your browser's time zone. Add Z or an offset like +05:30 so the date means the same instant everywhere.

A month shows as 4 weeks

A month is counted as 30 days, so 29 days is still weeks. Pick the month row from the breakdown if you prefer "1 month ago" earlier.

FAQ

How do I show "3 days ago" in JavaScript?

Use Intl.RelativeTimeFormat: new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(-3, 'day') returns "3 days ago". You calculate the difference and choose the unit yourself; the API handles the wording and plurals for every locale. The thresholds in the table above are a reasonable default for choosing the unit.

What is the difference between numeric auto and always?

With auto, the formatter uses special words where a language has them: "yesterday", "tomorrow", "last week", "next year", "now". With always, every value is a number: "1 day ago", "in 1 week", "in 0 seconds". auto reads more naturally in feeds and comments; always keeps columns consistent.

Which languages are supported?

Every locale your browser ships data for, which in current browsers covers hundreds of languages and regional variants, including Hindi, Tamil, Bengali, Arabic, Chinese and Japanese. The output is the same as your users' browsers would produce with Intl.RelativeTimeFormat, so what you see here matches your app.

How is this different from the Date Formatter?

The Date Formatter prints an absolute date in a fixed pattern, such as 26 Sep 2026, 2:05 PM. The Relative Time Formatter describes the distance from now. Interfaces often show relative time and put the absolute date in a tooltip, so both are useful for the same value.

Does relative time update automatically?

The phrase here is computed when you enter the date. In your own interface, re-render periodically — every minute for recent items, less often for older ones — because "30 seconds ago" quickly becomes wrong. Always keep the underlying timestamp and format it at display time.

Is the date I enter stored anywhere?

No. Formatting runs in your browser inside an isolated frame that blocks network requests. Your locale choice is remembered on this device; the dates are not stored unless you turn on "Remember my last input".

How the unit is chosen

The formatter picks the largest unit that fits at least once, using fixed lengths:

If the difference is at least Unit
365 days years
30 days months
7 days weeks
1 day days
1 hour hours
1 minute minutes
otherwise seconds

The value is then rounded, so 89 days shows as "in 3 months" and 29 days as "4 weeks ago".

Show the absolute date with the Date Formatter, convert epoch values with the Unix Timestamp Converter, or format a span like PT3H with the Duration Formatter. More in Date & Number.

Browse all Date, Time & Number Formatting