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

From 1 January 2025 to 1 January 2026.

Years
1
Months
0
Days
0
Total days
365
Total weeks
52.1
Total hours
8,760

That is about 52.1 weeks apart.

Was this useful?

Examples

How It Works

Formula

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

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

Variables

Δ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)

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.

Frequently Asked Questions

01How 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.
02Does 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.
03Are 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.
04What 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.
05Can 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.

All calculators