ToolActToolAct

Date Difference Calculator

Calculate days, weeks, months, years between two dates

Calculate the interval between two dates

What is a Date Difference Calculator?

A date difference calculator measures the gap between two calendar dates and expresses it as days, weeks, approximate months, approximate years, and smaller units such as hours or minutes. Typical checks include project duration, leave ranges, invoice periods, anniversaries, retention windows, and simple historical intervals. The result should be understood as a date interval, not automatically as an inclusive count: January 1 to January 3 is a two-day difference unless your business rule says to count both endpoints. Months and years are often approximate because calendar months do not have equal length. For workdays, holidays, time zones, or legal deadlines, use the relevant rule set instead of relying only on the plain difference.

How to Use

How to use

  1. Enter the start date
  2. Enter the end date
  3. Click 'Calculate interval' to compare the two dates
  4. View results: days, weeks, months, years, hours, minutes, seconds

Counting Rules

  • Check whether your task needs an exclusive interval or inclusive counting; many business rules count both start and end dates.
  • For cross-timezone work, convert dates to the same timezone first, especially when hours or minutes matter.

Use Cases

Measure the exact day gap between two datesSelect start and end dates and calculate the interval in days, with additional totals for weeks, approximate months, approximate years, hours, minutes, and seconds. The calculation follows Gregorian rules, so 1900 is treated as a common year and 2000 is treated as a leap year, which matters when either endpoint sits near February 29.
Check elapsed time for events and recordsUse it for subscriptions, service periods, travel spans, project timelines, anniversaries, study streaks, and any record where counting manually across months is error-prone. Keep the two source dates beside the result so the interval can be checked later, since a stated '36 months' is much harder to audit than the raw start and end pair.
Use approximate month and year values carefullyThe primary result is days. Month and year values are approximate summaries, so billing periods, legal age, and contractual rules should use the specific rule required by that context. Use the approximate values for orientation, not for final policy decisions. ISO week numbers, where week 1 contains the first Thursday of the year, are another convention the simple day count does not produce on its own.
Decide inclusive vs exclusive counting before quoting the gapFor leave ranges and trial periods, agree in advance whether both endpoints are counted, then label the result as 'between' or 'spanning' so legal, HR, and finance reports do not diverge. The off-by-one looks trivial on a single range but compounds across HR, payroll, and finance exports when the convention is not applied everywhere.
Cross-check approximate months against the specific calendarWhen a billing cycle, probation period, or warranty window is defined in months or years, run the same pair through a calendar-aware rule to confirm the approximate value matches policy. Mixing the two units in the same report is a common source of contract disputes, especially for B2B SaaS renewals where the same customer is on a 30-day and a calendar-month plan. Anniversary clauses that say '12 months from the start date' usually mean exactly one calendar year, not 365 days, so a Jan 15 start becomes Jan 15 of the next year, not Jan 14 or Jan 16.

Technical Principle

The exact day difference is computed as Math.floor((end.getTime() - start.getTime()) / 86_400_000), where 86,400,000 is the number of milliseconds in a non-DST 24-hour day. This gives an exclusive interval - January 1 to January 3 is 2 days, not 3 - because the subtraction measures the span between two instants rather than counting calendar squares. For inclusive counting (count both endpoints), add 1 to the result; many legal, leave, and billing rules require this and the off-by-one is the single most common cause of disagreements between HR and finance reports. Weeks are simply days / 7; the page also displays hours = days * 24, minutes = days * 1440, and seconds = days * 86,400 as derived totals. Month and year differences are deliberately labeled "approximate" because calendar months and years vary in length. The simple approach is days / 30.436875 (average Gregorian month) and days / 365.2425 (average Gregorian year over a 400-year cycle), which is fine for status reports and dashboards but wrong for contracts. For a calendar-accurate "X full months between", the algorithm subtracts year x 12 + month components and then decrements by 1 if the end day-of-month is earlier than the start day-of-month - this is how most date libraries (date-fns differenceInMonths, dayjs $.diff('month'), Temporal Duration.from) compute it. Year math has the same quirk: 2024-02-29 to 2025-02-28 is sometimes counted as 1 year (clamping to month-end) and sometimes as 0 years 11 months 30 days, depending on the convention. Leap years follow the Gregorian rule (divisible by 4, except centuries not divisible by 400, so 1900 = common, 2000 = leap, 2024 = leap). A span that includes February 29 picks up an extra day automatically because the day count is anchored on milliseconds since epoch, not on calendar fields. Timezone handling is critical when the two endpoints are at sub-day resolution: subtracting two Date values constructed from local-time strings can be off by the local UTC offset, and a span that crosses a DST transition can be 23 or 25 hours rather than the nominal 24. The Y2038 problem (Unix time_t signed 32-bit overflow on 2038-01-19T03:14:07Z) does not affect this page because JavaScript Date uses a 64-bit float capable of representing dates up to roughly 100 million days either side of the epoch, but downstream systems written in 32-bit C still need attention.

  • Exact days = Math.floor((end - start) / 86_400_000); 86.4M ms per non-DST day.
  • Result is exclusive by default: Jan 1 to Jan 3 = 2 days; add 1 for inclusive counting (both endpoints).
  • Approximate month uses average 30.436875 days; year uses 365.2425 days over the 400-year Gregorian cycle.
  • Calendar-accurate month diff: (y2-y1)*12 + (m2-m1) then -1 if end day < start day - matches date-fns differenceInMonths.
  • Leap years: divisible by 4, except centuries must be divisible by 400 (1900 no, 2000 yes, 2024 yes).
  • DST transitions create 23h and 25h calendar days; a 24h subtraction may not equal one calendar day.
  • JavaScript Date is a 64-bit float, immune to Unix Y2038 (32-bit time_t overflow at 2038-01-19 03:14:07 UTC).

Examples

Two full calendar years (2025-01-01 to 2026-12-31)

Start : 2025-01-01
End   : 2026-12-31

Days     : 730
Weeks    : 104.29
Months   : ~24.00 (approx)
Years    : ~2.00 (approx)
Note     : 2028 is the next leap year in range, so the span includes Feb 29 2028 when extended.

Short interval (3 days)

Start : 2026-06-11
End   : 2026-06-14

Days     : 3
Hours    : 72
Minutes  : 4320
Seconds  : 259200
Inclusive count (count both ends): 4 days

Project duration across a year boundary

Start : 2026-01-15  (kickoff)
End   : 2026-07-20  (go-live)

Days     : 186
Weeks    : 26.57
Months   : ~6.16
Use case : Status reports, retrospective, gantt summary

Age calculation in days

Birthday      : 1995-03-15
Today         : 2026-06-11

Days alive    : 11,411
Years (approx): 31.24
Months        : ~374.9
Useful when an exact day count is needed (e.g. milestones)

Timezone caveat (Tokyo vs Los Angeles)

Same calendar date '2026-07-15' carries different real instants:
  Tokyo  (UTC+9)  -> 2026-07-15 00:00 = 2026-07-14 15:00 UTC
  Los Angeles (UTC-7) -> 2026-07-15 00:00 = 2026-07-15 07:00 UTC
Difference if used naively: about 16 hours, enough to flip a 1-day result.
Fix: convert both dates to the same timezone before subtracting.

FAQ

How is the difference between two dates calculated?

Calendar arithmetic: the result is shown as years, months, and days plus the total in weeks, days, hours, minutes, and seconds. Years and months are anniversary-based (the years count goes up only after the same month/day passes), and days are the calendar-day count between the two dates.

Why do years + months + days not sum cleanly to total days?

Because months are 28-31 days. '1 year, 2 months, 5 days' is a different number of total days depending on whether the months involved have 28, 29, 30, or 31 days. The total-days field uses raw calendar arithmetic and is the most precise number.

Is the start day included or excluded?

The page reports the count exclusive of the start date - identical dates show 0 days difference. If you need 'inclusive' counting (e.g. for booking nights), add 1 to the result manually.

Are weekends or holidays excluded?

No. This page counts every calendar day. For business-day differences (skipping weekends and optionally holidays), use the 'Workday Calculator' tool.

Why does the time component look off after a DST change?

The hour-and-minute portion uses absolute time, so spanning a daylight-saving transition adds or subtracts an hour to the time-of-day field. The day count itself is unaffected because day differences are calendar-based.

What is the maximum date range I can compare?

JavaScript Date covers ±100,000,000 days from the Unix epoch, so any pair of historical or future dates within roughly ±271,000 years works. Pre-1582 dates use proleptic Gregorian arithmetic, which differs from the local calendar in use at the time.

Is the calculation done locally?

Yes. Both dates and the result stay in your browser. Nothing is uploaded or logged.