Date Difference Calculator

Find the exact difference between two dates in years, months, and days. Also shows total days, weeks, and hours between the dates.

Examples

One calendar year

From 1 January 2025 to 1 January 2026.

Start date
Jan 1, 2025
End date
Jan 1, 2026
Years
1
Months
0
Days
0
Total days
365
Total weeks
52.1
Total hours
8,760

Embed this calculator

Copy a free iframe snippet for articles, learning pages, forums, wikis, newsletters, and internal docs.

How It Works

Formula

totalDays=Δt86400000\text{totalDays} = \frac{\Delta t}{86400000}

totalHours=totalDays×24\text{totalHours} = \text{totalDays} \times 24

Variables, symbols and units

Δt\Delta t

Milliseconds between the earlier and later date (UTC)

totalDays\text{totalDays}

Whole calendar days between the two dates

totalHours\text{totalHours}

Total hours between the two dates

8640000086400000

Milliseconds in one day (24 × 60 × 60 × 1000)
Calculation method explained

Enter two dates. The calculator determines which is earlier, then computes the difference broken down into years, months, and days. It also calculates the total number of days, weeks, and hours between the two dates.

Calendar-style breakdown of the span between two dates:

  1. Sort the inputs so the earlier date comes first; the order you typed them in does not matter.
  2. Tentatively take the year, month, and day differences: years=laterYearearlierYear\text{years} = \text{laterYear} - \text{earlierYear}, months=laterMonthearlierMonth\text{months} = \text{laterMonth} - \text{earlierMonth}, days=laterDayearlierDay\text{days} = \text{laterDay} - \text{earlierDay}.
  3. If the day count is negative, the later date has not yet reached the same day-of-month as the earlier date — borrow the days of the previous month and subtract one from the months count.
  4. If the months count is then negative, the later month is still before the earlier month within the year — borrow 12 months and subtract one from the years count.
  5. Compute total elapsed time directly from the timestamps: totalDays=Δt/86400000\text{totalDays} = \Delta t / 86400000, totalWeeks=totalDays/7\text{totalWeeks} = \text{totalDays} / 7, totalHours=totalDays×24\text{totalHours} = \text{totalDays} \times 24. Dates are parsed as UTC midnight to avoid daylight-saving off-by-ones across the span.

Examples

One calendar yearJan 1, 2025 · Jan 1, 20261

From 1 January 2025 to 1 January 2026.

Start date
Jan 1, 2025
End date
Jan 1, 2026
Years
1
Project deadlineMar 15, 2026 · Sep 30, 20260

A project running from 15 March 2026 to 30 September 2026.

Start date
Mar 15, 2026
End date
Sep 30, 2026
Years
0
Historical spanJul 20, 1969 · Apr 25, 202656

From the moon landing (20 July 1969) to 25 April 2026.

Start date
Jul 20, 1969
End date
Apr 25, 2026
Years
56

Frequently Asked Questions

How is the difference calculated?
The calculator finds the earlier and later date, then counts full years, remaining full months, and remaining days — just like counting on a calendar. Total days are calculated separately as the absolute difference.
Does the order of dates matter?
No. The calculator automatically detects which date is earlier and computes the positive difference. You can enter either date first.
Are leap years handled?
Yes. The calculation uses actual calendar dates, so leap years with 366 days are counted correctly. February in a leap year has 29 days.
What format should I use for dates?
Use the ISO format YYYY-MM-DD (e.g. 2026-04-07 for 7 April 2026). This ensures consistent, unambiguous parsing regardless of locale.
Can I use this for weekday calculations?
This calculator counts every calendar day. Use the Weekdays Calculator when you want a weekday count with a days-not-counted pattern and optional extra dates you provide.

Related Calculators

All calculators