Date Difference Calculator Widget
Add a date difference calculator to your website. Visitors pick two dates, optionally with times, and see the gap as years, months and days as well as total days, weeks, hours and minutes.
Live preview
Exactly what your visitors will seeUnder the widget on your page: Powered by A2Z Tools
Embed code
<iframe src="https://a2z.tools/embed/w/date-difference-calculator" title="Date Difference Calculator by A2Z Tools" width="100%" height="570" style="border:0;width:100%" loading="lazy" allow="clipboard-write"></iframe>
A plain iframe. Works everywhere, including site builders that strip scripts. Adjust height if your content needs more room.
<div data-a2z-widget="date-difference-calculator" data-height="570"></div> <script async src="https://a2z.tools/embed.js"></script>
Adds a small script (what it does) that sizes the widget to fit its content, loads it lazily and keeps it isolated from your page's CSS.
Works with
How it works
The calculator counts whole months from the start date and then the remaining days, using the same month rules as the A2Z Age Calculator, and adds hours and minutes when times are given (borrowing a day if the end time is earlier in the day than the start time). Totals are exact differences of calendar-day numbers, so a range across a daylight-saving change is not an hour short. Tick "Include the end date" to count both ends, the way hotel nights or some notice periods are counted, which adds one day; this matches the A2Z Days Between Dates tool. If the end is before the start, the dates are swapped and a note says so.
Calculation method
- Whole months = (Y2 - Y1) x 12 + (M2 - M1), minus 1 if D2 < D1; remaining days after the last monthly anniversary
- With times: minutes = end time - start time; if negative, borrow one day (+1440 minutes)
- Total days = end day number - start day number (+1 when the end date is included)
- Total hours = total minutes / 60; weeks = floor(total days / 7)
Worked examples
A leap-year span
Inputs: Start 2024-01-01, end 2024-12-31
Result: 11 months, 30 days; 365 days, 8,760 hours. With the end date included: 1 year exactly, 366 days
2024 has 366 days, so the gap between its first and last day is 365.
A notice period across 29 February
Inputs: Start 2028-01-15, end 2028-03-15
Result: 2 months, 0 days; 60 days; 8 weeks and 4 days
2028 is a leap year, so these two calendar months hold 60 days instead of the 59 they would have in 2027.
An overnight shift with times
Inputs: Start 2026-10-01 22:15, end 2026-10-03 06:40
Result: 1 day, 8 hours, 25 minutes; 1,945 minutes; 32.42 hours
06:40 is earlier in the day than 22:15, so one day is borrowed and 8 h 25 min remain.
Limitations
- Both times are read in one time zone; a flight from Delhi to London cannot be measured by typing each local clock time.
- Weekends and holidays are not excluded - use the Business Days Calculator for working days.
- Times are to the minute, and totals in months or years are not given as decimals, because months differ in length.
Where publishers use it
- HR and payroll pages working out service length or notice periods
- Project-management blogs measuring time between milestones
- Legal and visa information sites counting days between two dates
- Anniversary and relationship sites showing how long since a date
Questions
Should I include the end date?
Leave it off to measure the gap (1 to 8 March is 7 days). Include it to count both days (8 days), as hotel stays and some contract periods are counted.
Does daylight saving change the result?
No. Dates are calendar days and times are wall-clock times in a single zone, so the hour lost or gained at a clock change is not applied.
How many days are in a year here?
Every real calendar day is counted, so leap years have 366 days; 1 January to 31 December 2024 is 365 days apart.
Can I enter times as well?
Yes. Add start and end times to get hours and minutes too.
Why is 31 January to 28 February shown as 28 days, not one month?
A whole month is only complete when the same day number is reached again, and February has no 31st. So the span is 0 months and 28 days; 31 January to 1 March is exactly one month.
Sources
- chrono-Compatible Low-Level Date Algorithms (days_from_civil) - Howard Hinnant . Exact day counts across leap years in the proleptic Gregorian calendar
- ISO 8601 date and time format - ISO . YYYY-MM-DD dates and HH:MM times
Cite or recommend this tool
If you reference this tool in an article, course or documentation, these formats are ready to copy. They are optional - nothing is added to your site unless you paste it.
A2Z Tools Date Difference Calculator https://a2z.tools/days-between-dates
<a href="https://a2z.tools/days-between-dates">A2Z Tools Date Difference Calculator</a>
[A2Z Tools Date Difference Calculator](https://a2z.tools/days-between-dates)
Date Difference Calculator by A2Z Tools - https://a2z.tools/days-between-dates
Related widgets
-
Exact age in years, months and days, totals in months, weeks and days, and the next birthday.
-
Count working days between dates or add N business days, with your weekend and holidays.
-
Live days, hours, minutes and seconds to a date you set, with an "event has started" message.
-
A keyboard-friendly month calendar with today highlighted and your own marked dates.
-
Convert a date and time between any two time zones, with daylight-saving gaps and overlaps explained.
-
A large live digital clock for any time zone, with seconds, date and a 12/24-hour switch.