Skip to main content

Relative Time Calculator

Compare two dates and times and get the natural relative phrase (“3 months ago”, “tomorrow”, “in 2 hours”) together with the exact gap in days, hours, minutes and seconds.

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

How does this tool work?

“Posted 3 days ago”, “expires in 2 hours”, “updated 4 months ago”: interfaces and content often describe a date relative to a reference moment. This calculator compares two date-times and shows the relative phrase a browser would produce in your language, along with the exact gap in days, hours, minutes and seconds. Use it to check a label, write a notification or simply find out how much time separates two moments.

The tool first computes the real gap in seconds between the target and the reference (positive when the target is in the future). It then picks the largest unit reached: years from 365 days, months from 30 days, weeks from 7 days, then days, hours, minutes and seconds.

The gap is divided by the length of that unit and rounded to the nearest whole number, the same way in the past and in the future: 45 days give “in 2 months” just as they give “2 months ago”. A month counts as 30 days and a year as 365 days — average lengths, so the result is a readable approximation, not a calendar calculation.

The phrase comes from the browser’s Intl.RelativeTimeFormat API (ECMA-402 standard, wording from Unicode CLDR data) with the numeric option set to “auto”: a value of 1 or −1 becomes “tomorrow”, “yesterday”, “next week” or “last month”, and a zero gap becomes “now”. Dates are read in your device’s time zone.

How to use this tool

  1. Enter the reference date and time

    This is “now” from the phrase’s point of view, for example the current time.

  2. Enter the target date and time

    The event to place: in the past (… ago) or in the future (in …).

  3. Read the relative phrase

    It is shown in the language of the page.

  4. Check the exact gap

    The breakdown in days, hours, minutes and seconds shows the rounding applied.

How the unit is chosen

The value shown is the gap rounded in the largest unit reached.

Gap in seconds

Δ = t(target) − t(reference)

Value shown

v = sign(Δ) × round(|Δ| ÷ u)

u is the largest unit such that |Δ| ≥ u.

Δ
real gap in seconds, negative in the past
u
unit length: 1 year = 365 d, 1 month = 30 d, 1 week = 7 d, 1 d = 86,400 s, 1 h = 3,600 s, 1 min = 60 s
v
number shown in the relative phrase

Date libraries do not all use the same thresholds: some switch to months from 26 days or never show weeks. Two websites can therefore phrase the same gap differently.

Use cases

Check an interface label

Make sure a “2 months ago” shown by an app matches the real dates.

Write a notification or reminder

Get the natural phrasing of a deadline in the six languages of the site.

Measure the time since an event

Find the exact gap between an order and its delivery, or between two logins.

Understand a one-hour shift

Spot the effect of a daylight saving change on a one-day gap.

Examples

Rounding to months

45 ÷ 30 = 1.5, rounded to 2.

Input

Reference 9 Oct 2026 12:00, target 23 Nov 2026 12:00

Result

in 2 months (exact gap: 45 d)

Rounding to hours

1.5 h is rounded to 2 h.

Input

Reference 12:00, target 13:30 the same day

Result

in 2 hours (1 h 30 min)

In the past

1,012 days ÷ 365 ≈ 2.77, rounded to 3.

Input

Reference 9 Oct 2026, target 1 Jan 2024

Result

3 years ago

Spring-forward day (Paris)

The night of 28 to 29 March lasts only 23 h: the tool measures the time that actually elapses.

Input

Reference 28 Mar 2026 12:00, target 29 Mar 2026 12:00

Result

in 23 hours

Tips and best practices

  • “Tomorrow” here means a gap rounded to one day (24 h to under 36 h), not necessarily the next calendar day: 23:00 to 05:00 two days later also gives “tomorrow”.
  • For an exact number of calendar days between two dates, use the date difference calculator; for a countdown in days, the days until date calculator.
  • For a precise duration shown to users (legal deadline, warranty), prefer the exact gap over the rounded phrase.
  • To compare times entered in two different time zones, convert them first with the time zone converter.

Sources and references

Frequently asked questions

Why do 45 days give “in 2 months”?

Beyond 30 days the gap is expressed in 30-day months and rounded: 45 ÷ 30 = 1.5, rounded to 2. The exact gap (45 d) is still shown below the phrase.

Why “in 4 weeks” for 29 days?

Months only start at 30 days. Between 7 and 29 days, the gap is expressed in weeks: 29 ÷ 7 ≈ 4.1, rounded to 4.

Why does a one-day gap show 23 or 25 hours?

Because a daylight saving change happened between the two dates. The tool measures the time that actually elapsed in your device’s time zone.

When does the tool show “yesterday” or “tomorrow”?

When the rounded gap is exactly −1 or +1 day. The same goes for “last week”, “next month” or “next year”.

Where does the wording in each language come from?

From the browser’s Intl.RelativeTimeFormat API, defined by the ECMA-402 standard and fed by Unicode CLDR language data.

Are seconds taken into account?

The fields are entered to the minute, but the gap is computed in seconds; under one minute the result is expressed in seconds or as “now”.

Related tools

Tools similar or complementary to this one.

Similar tools

Calculate the time between two dates in years, months and days, in total days and in weeks.

Dates & timeFeaturedUse this tool

Find out how many days are left until a date, or how many have passed since, with the equivalent in weeks.

Dates & timeFeaturedUse this tool