Why counting days is harder than subtraction
The obvious way to find the gap between two dates is to subtract one from the other. In software, that works perfectly — dates stored as Unix timestamps are just integers, and the difference divided by 86,400 gives you days. This tool's "total days" figure uses exactly that: millisecond arithmetic, then divided and rounded.
But "how old am I in years and months?" requires calendar-aware arithmetic, and that's where it gets complicated.
The calendar-month problem
Not all months have the same number of days. January has 31, February has 28 (or 29), and so on. This means "one month from January 31" has no direct answer — there is no February 31. JavaScript's Date.setMonth() handles this by rolling over: adding one month to January 31 gives March 3 (or March 2 in leap years). Most people would expect February 28 instead, so the tool explicitly handles the end-of-month edge case.
The breakdown of years, months, and days you see in this tool is computed the same way a person would count: "how many full years fit, then how many full months remain, then how many spare days?" This matches how age, lease periods, and loan tenures are conventionally stated.
Leap years and date offsets
When you add one year to a date, most of the time it's simple: 2024-03-15 → 2025-03-15. But 2024-02-29 → 2025-02-29 doesn't exist, so the result becomes 2025-02-28. JavaScript's Date.setFullYear() handles this automatically, which is why the "add/subtract" mode in this tool handles leap year boundaries correctly without special-case code.
The total-days count between 2024-01-01 and 2025-01-01 is 366, not 365, because 2024 is a leap year. Millisecond arithmetic handles this correctly.
Business days vs calendar days
This tool counts calendar days only. For business-day calculations, you'd also need to exclude weekends and public holidays. Public holidays vary by country and even by state — a genuine business-day counter needs a database of holidays, which this tool doesn't include. If you need business days, the approach is: calculate calendar days, then subtract weekends (floor(days/7) × 2 + adjustments for partial weeks), then manually subtract holidays in the range.
Practical uses
The "days between dates" mode is useful for lease expiry, contract duration, age milestones, countdown timers, and interest calculations on short-term lending. The "add/subtract" mode is useful for deadline arithmetic — "90 days from today", "6 months from contract date", "2 years before expiry".