Date Difference Calculator
Calculate the exact difference between two dates in years, months, days, weeks, hours and minutes.
Reviewed by Aygul Dovletova · Last reviewed
How to Use the Date Difference Calculator
- Pick a start date in the first
<input type="date">field. The picker uses your browser's locale, so the visual format is whatever Chrome, Firefox, or Safari renders for your system region, but the underlying value is always ISO 8601YYYY-MM-DD. - Pick an end date in the second field. Order does not matter; the tool takes the absolute difference.
- Read the breakdown: the result panel shows a calendar-aware split (years, months, days) alongside flat totals (total days, weeks, hours, minutes, seconds).
- Copy the value you need with the copy icon next to each metric.
Both the "calendar" answer ("1 year, 2 months, 5 days") and the "arithmetic" answer ("430 days") are shown on purpose - they are genuinely different questions and people reach for this tool for both.
What This Tool Actually Computes
Under the hood the component parses each date string into a Date object anchored at local midnight, then does two independent calculations. For the flat total it subtracts the two epoch millisecond values and divides by 86,400,000 - simple and accurate because JavaScript's epoch is already UTC-based and ignores leap seconds. For the calendar breakdown it walks year-month-day using getFullYear(), getMonth(), and getDate(), borrowing days from the previous month the way long-form subtraction does. This is the part that trips people up: "1 month" from January 31 to February 28 is not the same length as "1 month" from July 31 to August 31. The Gregorian calendar has irregular month lengths (28, 29, 30, or 31 days), and any honest difference tool has to decide how to deal with that.
When You Would Reach for This
- Working out how many calendar days you have left on a visa, passport, or lease where the counter is literal days, not working days.
- Figuring out exactly how old a child is in weeks for a pediatric milestone chart, or how many days a pet has been alive.
- Reconstructing a statute-of-limitations window where you need the calendar answer plus a raw day count as a cross-check.
- Measuring the time between two commits, releases, or incidents for a post-mortem timeline.
- Counting days on a subscription renewal or a pro-rata refund where fractional months matter.
- Preparing evidence for an invoice dispute that hinges on whether a payment arrived in 30 days or 31.
Edge Cases Worth Knowing
- Leap years. 2024 had a February 29. Someone born on Feb 29, 2000 has had exactly six "real" birthdays as of 2024. The tool counts Feb 29 as a day like any other; JavaScript's
Datehandles the Gregorian leap rule (divisible by 4, except centuries not divisible by 400) natively. - Daylight saving transitions. Local midnight on the day DST shifts is either 23 or 25 hours from the previous midnight. The tool sidesteps this by anchoring to
T00:00:00local and using UTC epoch math for totals, so "days" stays whole even on DST boundaries. - Timezone drift. If the start date came from a colleague in another zone and the end date is yours, you may be off by one day. ISO 8601 dates without a timezone are underspecified - a hard lesson from "Falsehoods Programmers Believe About Time."
- The Julian-to-Gregorian switch (1582). JavaScript's proleptic Gregorian calendar pretends Gregorian rules ran all the way back to year 1. Historical dates before October 15, 1582 will not match contemporaneous records.
- Year 0 does not exist in the Anno Domini convention, but it does exist in ISO 8601 and in
Date. Spans crossing 1 BC / 1 AD off-by-one are a real footgun.
The ISO 8601 Spec in One Paragraph
ISO 8601 is the international standard (first published 1988, current edition ISO 8601-1:2019) that defines YYYY-MM-DD and the extended form with time YYYY-MM-DDTHH:mm:ss[.sss]Z. It is designed so string-sort order equals chronological order, which is why it is the sane default for log lines and filenames. RFC 3339 is a stricter profile of ISO 8601 used in internet protocols - it is what Date.prototype.toISOString() produces. The IANA Time Zone Database (also called the Olson database, after founder Arthur David Olson) is the authoritative source of historical DST transitions, political boundary changes, and fractional-hour offsets like India's UTC+5:30 and Iran's UTC+3:30. Your browser ships a snapshot of that database via the Intl API.
Date Diff in jq, Python, Excel, or Just This Page
For one-off calculations this page is faster than spinning up Python or a spreadsheet. Excel's DATEDIF(start, end, "d") gives total days but the "m" unit rounds weirdly around month-end (a known bug Microsoft has documented but never fixed). Python's datetime subtraction yields a timedelta that exposes .days and .total_seconds() but no calendar breakdown - you would need dateutil.relativedelta for "1 year 2 months 5 days" output. The date CLI on macOS/BSD uses a different flag set than GNU date on Linux, which is its own source of pain. This tool is the right pick when you want both views at once, you do not trust Excel's month math, and you do not want to write a five-line script for a one-minute question.
Frequently Asked Questions
Why does the calendar breakdown say "1 month" but the total says "30 days" and "31 days" for similar inputs?
Because calendar months are not a fixed length. The tool computes year/month/day by borrowing the way you did in grade-school subtraction, so the "month" unit inherits the actual length of the month you are leaving. Between March 1 and April 1 is 31 days; between February 1 and March 1 (non-leap year) is 28 days - both are "1 month." The flat-total row is there precisely so you can cross-check the calendar answer against an unambiguous integer.
Does this handle February 29 correctly for people born on a leap day?
Yes. The component uses native JavaScript Date arithmetic, which follows the Gregorian leap rule (every 4 years, except years divisible by 100 unless also divisible by 400). A person born Feb 29, 2000 is treated as having a real birthday on Feb 29, 2004, 2008, 2012, and so on. In non-leap years the tool still gives a correct count of days elapsed since birth; how a human chooses to "celebrate" the missing day (Feb 28 vs. March 1) is a social convention, not a math problem.
Why do my dates sometimes look one day off compared to a colleague?
The date picker yields an ISO date string without a timezone, and your browser interprets it at local midnight. If you are in Tokyo and your colleague is in Los Angeles, their "2024-05-15 midnight" is already "2024-05-15 afternoon" for you. The fix is to agree on a reference zone (usually UTC) and convert before comparing. This is number four on the "Falsehoods Programmers Believe About Time" list and it is the single most common source of date bugs.
Does anything about my input get sent over the network?
No. The component is a Preact island rendered into the static Astro page; once the JavaScript bundle is delivered, all parsing and subtraction happens in the tab. There is no fetch call to a backend, no service worker intercept, and no analytics on the input values themselves - the only telemetry is the page view that Astro already logs.
Can I use it for historical dates like 1600 or 800 AD?
You can, but interpret the answer carefully. JavaScript Date uses the proleptic Gregorian calendar, which pretends the Gregorian rules applied retroactively before October 15, 1582. Real historical documents before that date use the Julian calendar (or other regional calendars for non-Catholic regions, which switched as late as 1923 for Greece and 1918 for Russia). For genealogical or historical research, convert to Julian Day Number first if you need to match primary sources.
Why is the hours total not always an exact multiple of 24?
Normally it is, because the calculation uses local midnight on both ends. But if you are in a DST-observing zone and the interval crosses spring-forward or fall-back, the elapsed UTC milliseconds for that day is 23 or 25 hours. The tool rounds "days" so you do not see 30.04, and keeps the exact hours row for DST-aware math.
How is this different from a "countdown to a date" tool?
A countdown is a live timer that ticks every second to a future target. A date difference is a static snapshot between two chosen points, past or future. The cases overlap ("how long until launch?") but countdowns need a clock tick and date diffs do not. For a live countdown see our Countdown Timer.
Can I get the result in business days instead of calendar days?
Not on this page - this tool gives calendar spans only. Use the Business Days Calculator for Mon-Fri counts with optional holiday exclusions. "Business days" is regional: most Western countries use Mon-Fri, several Gulf countries historically used Sun-Thu.
Why show weeks as a separate unit instead of just dividing days by 7?
That is exactly what the tool does - there is no independent "weeks" math. It is shown as its own row because people planning sprints, pregnancies, or gestational milestones think natively in weeks, and manually dividing feels like friction. The fractional part is truncated; if you need the remainder, read the "days" field alongside it.
Does a leap second change the result?
No. JavaScript time, Unix time, and ISO 8601 all ignore leap seconds. The last one was inserted December 31, 2016, and the IERS has voted to stop adding them by 2035. For counting calendar days this is a non-issue; for total elapsed seconds between two timestamps decades apart the answer is off by about 27 seconds from UT1 - invisible for any practical purpose.
More Date & Time
Business Days Calculator
Count business days between two dates excluding weekends and custom holidays.
Open toolCountdown Timer
Set a target date and time, then watch a live countdown showing days, hours, minutes and seconds.
Open toolDate Formatter
Format any date in 12 patterns including ISO 8601, US, EU, RFC 2822, Unix timestamp and relative.
Open toolPomodoro Timer
25-minute work and 5-minute break cycles with progress bar, session counter and phase tracking.
Open toolStopwatch
Precise online stopwatch with start, stop, reset and lap time recording. Centisecond accuracy.
Open toolTimezone Converter
Convert times between timezones instantly. Supports 28+ world timezones with DST handling.
Open tool