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.

Time & Date Calculator Runs in your browser Free · no ads

Customize your widget

Theme
Auto follows the visitor's light/dark setting.
Style
Attribution on your page
Optional and entirely your choice. The exact line is shown in the code below; it links to the tool with rel="nofollow".
More options
Starting values
Leave blank to use the widget's defaults. Visitors can still change every value.

Live preview

Exactly what your visitors will see

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.

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.

Can it count working days or notice periods?

No - it counts every calendar day, weekends and bank holidays included. For a resignation notice, a refund window or a court filing deadline measured in business days, use a working-days calculator and check the governing rule, because some laws count only weekdays and others exclude the first day.

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.

Why might a contract or visa count differ from this result?

Legal periods often have their own rules: some exclude the day of the event, some end on the same date in a later month, and some move a deadline that falls on a weekend or holiday. This widget reports plain calendar arithmetic, so check the governing clause, statute or immigration guidance before relying on a count.

Is anything I enter stored?

No. Both dates stay in the visitor's browser and the widget makes no network request.

What are typical uses on a website?

Pregnancy and baby blogs counting weeks between dates, wedding and travel sites showing nights booked, HR pages working out length of service, and project or course pages showing how long a programme runs. Preset v_start and v_end in the builder so the example readers see matches your topic.

Which calendar does it use?

The proleptic Gregorian calendar used by ISO 8601 and by browsers, so dates before 1582 are treated as if the Gregorian rules had always applied. Historical Julian dates need converting first.

Sources

  1. chrono-Compatible Low-Level Date Algorithms (days_from_civil) - Howard Hinnant . Exact day counts across leap years in the proleptic Gregorian calendar
  2. 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
  • Age Calculator

    Time & Date Calculator

    Exact age in years, months and days, totals in months, weeks and days, and the next birthday.

    Get code
  • Business Days Calculator

    Time & Date Calculator

    Count working days between dates or add N business days, with your weekend and holidays.

    Get code
  • Countdown Timer

    Time & Date Clock & time

    Live days, hours, minutes and seconds to a date you set, with an "event has started" message.

    Get code
  • Calendar

    Time & Date Tool

    A keyboard-friendly month calendar with today highlighted and your own marked dates.

    Get code
  • Time Zone Converter

    Time & Date Converter

    Convert a date and time between any two time zones, with daylight-saving gaps and overlaps explained.

    Get code
  • Digital Clock

    Time & Date Clock & time

    A large live digital clock for any time zone, with seconds, date and a 12/24-hour switch.

    Get code

Preview