Date Difference Calculator
Calculate the precise span between any two dates — how many days, weeks, months, and years separate them. Useful for contract durations, project timelines, age verification, and planning.
How It Works
The difference between two dates seems simple until you realize that months have different lengths and years have leap days. This calculator handles all of that correctly.
Total days: The most reliable unit. JavaScript converts both dates to Unix timestamps (milliseconds since 1 January 1970) and divides the difference by 86,400,000 (milliseconds in a day). This automatically handles all leap years.
Worked example: From 1 January 2000 to 15 June 2023.
Counting directly: this span includes 6 leap years (2000, 2004, 2008, 2012, 2016, 2020).
Regular years contribute 17 × 365 = 6,205 days.
Leap years add 6 extra days.
Plus partial year 2023: January (31) + February (28) + March (31) + April (30) + May (31) + 15 days of June = 166 days.
Total = 6,205 + 6 + 166 = 8,377 days.
Total weeks: 8,377 / 7 = 1,196 complete weeks, 5 remaining days.
Total hours: 8,377 × 24 = 201,048 hours.
Years/months/days (combined): This uses the same graduated subtraction algorithm as the age calculator. Start from the later date and work backwards: subtract whole years, then months, then days, borrowing from larger units when needed.
For 1 Jan 2000 to 15 Jun 2023: 23 years, 5 months, 14 days.
Check: 23 years from 1 Jan 2000 = 1 Jan 2023. 5 months later = 1 June 2023. 14 days later = 15 June 2023. ✓
The years/months/days breakdown is useful for contracts ("3 years, 6 months from signing"), leases, and human-readable durations. Total days is better for precise calculations, deadlines, and interest accrual.
Frequently Asked Questions
Why does the number of months seem off?
Month-counting is genuinely ambiguous. From January 31 to March 1 is either "1 month" (Feb is skipped) or "1 month, 1 day" or "29/30/31 days" depending on method. This calculator counts whole calendar months (periods where the day-of-month has cycled), which is the most natural interpretation.
Does this include both the start and end date?
The default counts from the start of the start date to the start of the end date — so it does not include the end date itself (as a boundary). If you need to include both endpoints, add 1 to the total days.
How many days are in a year for this calculator?
The calculator uses actual calendar days, so it counts 365 days in regular years and 366 in leap years. It does not assume a 365.25-day average year.
Can I use this for interest calculations?
The total days figure is useful for simple-interest calculations that use actual/365 or actual/360 day count conventions. For example, if your bank uses actual/360, divide total days by 360 to get the exact interest period as a fraction of a year.
How far in the future or past can I calculate?
JavaScript's Date object handles dates from roughly 271,821 BCE to 275,760 CE. For practical purposes, any historical or near-future date you are likely to need will work.