Calculator Hours Between Two Dates: How to Use
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator works out the total number of hours between any two dates and times. You enter a start date and time and an end date and time, and you get back the exact hour count, plus the equivalent in days and minutes. The result is the true elapsed time, so it correctly handles dates that span midnight, multiple days, or even months.
Formula
The calculator converts both dates to a single number: milliseconds since January 1, 1970 (the Unix epoch). It then subtracts the start from the end and divides by the number of milliseconds in an hour.
Total hours = (End time − Start time) / 3,600,000
- End time — the later date and time, in milliseconds since the epoch
- Start time — the earlier date and time, in milliseconds since the epoch
- 3,600,000 — milliseconds in one hour (1000 ms × 60 s × 60 min)
The same subtraction also gives you whole days by dividing by 86,400,000 (milliseconds per day) and minutes by dividing by 60,000.
Worked Example
Using the default values: start = January 1, 2025, 09:00; end = January 3, 2025, 17:30.
- Convert both to milliseconds since the epoch. The difference is 2 days, 8 hours, and 30 minutes.
- Total minutes = 2 × 24 × 60 + 8 × 60 + 30 = 2,880 + 480 + 30 = 3,390 minutes.
- Total hours = 3,390 ÷ 60 = 56.5 hours.
- Whole days = floor(56.5 ÷ 24) = 2 days.
- Total minutes = 3,390 minutes.
The calculator shows 56.50 hours, 2 whole days, and 3,390 minutes — matching the manual arithmetic.
Why You Might Need This
People often need the exact hour count between two dates for:
- Calculating billable work hours across multiple days
- Figuring out how long a project or trip actually lasts
- Checking time remaining until a deadline or event
- Comparing durations of different activities or processes
- Converting a date range into hours for payroll or scheduling
The result is a continuous elapsed time, not a count of business hours. If you need only working hours (9–5, weekdays), this basic calculator won’t do that — you’d need a separate tool that excludes weekends and holidays.
How to Read the Result
The headline answer is the total hours, shown as a decimal. For example, 56.50 hours means 56 hours and 30 minutes (0.50 × 60 = 30). The whole-days output tells you how many full 24-hour periods fit inside that span, and the total minutes is simply the hours multiplied by 60.
One common confusion: “days� here means 24-hour blocks, not calendar days. If you start at 9 AM on Monday and end at 9 AM on Tuesday, that’s 1 whole day and 24 hours. If you start at 9 AM Monday and end at 5 PM Tuesday, that’s 0 whole days (because 32 hours is less than 48) but 32 total hours.
Common Mistakes and Pitfalls
- Mixing AM and PM — 9:00 vs 21:00 is a 12-hour error. Always use 24-hour time or double-check AM/PM.
- Ignoring the date — If you only enter times, the calculator assumes the same day. A start at 10 PM and end at 2 AM needs the end date to be the next day.
- Daylight saving time — This calculator uses UTC internally, so it does not adjust for DST. In regions with DST, the actual clock time difference may be 23 or 25 hours on transition days.
- Leap seconds — These are rare and ignored here; they don’t affect typical calculations.
- Time zone confusion — If you enter times in different time zones, the result will be wrong. Use the same time zone for both inputs.
Limitations of the Formula
The formula is simple subtraction, so it works for any two valid dates, but it has limits:
- It assumes every day is exactly 24 hours, which is true for UTC but not for local time in DST zones.
- It cannot handle dates before 1970 on some systems (though modern browsers support earlier dates).
- It gives elapsed time, not calendar-based counts like “3 business days� or “2 months.�
- It doesn’t round to the nearest hour — you get a precise decimal, which is usually what you want.
For most practical purposes — project timelines, travel duration, age in hours — this is exactly correct. For payroll or legal deadlines, check whether you need calendar days or business hours instead.
Alternatives and Related Calculations
If you need a different kind of date math, consider these:
- Days between two dates — gives a whole number of days, ignoring time-of-day.
- Business days calculator — counts weekdays only, optionally excluding holidays.
- Age calculator — typically shows years, months, and days, not hours.
- Time duration calculator — for times on the same day, like 9:00 to 17:00.
Each serves a different purpose. The hours-between-dates calculator is the right tool when you need a precise continuous duration that spans multiple calendar days.
Frequently Asked Questions
How do I calculate hours between two dates manually?
Convert both dates to a common unit (like minutes or milliseconds), subtract the earlier from the later, then divide by 60 to get hours. For example, from Jan 1 09:00 to Jan 3 17:30, convert to minutes: (2 days × 1440) + (8.5 hours × 60) = 2880 + 510 = 3390 minutes, then divide by 60 = 56.5 hours.
Does this calculator account for daylight saving time?
No. It uses UTC internally, so it treats every day as exactly 24 hours. If you live in a DST region, the actual clock difference on a spring-forward or fall-back day will be 23 or 25 hours. For most planning purposes, the UTC result is fine, but for exact local time, you may need to adjust manually.
What if my end date is before my start date?
The calculator will return a negative number. That’s a sign you entered the dates in the wrong order. Swap them to get a positive duration. Negative values are not meaningful for elapsed time.
Can I calculate business hours (9–5) with this?
No. This tool gives continuous elapsed hours, including nights and weekends. To count only working hours, you need a business-hours calculator that excludes weekends and optionally holidays. That requires a more complex formula beyond simple subtraction.
How do I convert the decimal hours to hours and minutes?
Take the decimal part and multiply by 60. For example, 56.50 hours → 0.50 × 60 = 30 minutes, so it’s 56 hours and 30 minutes. If you get 56.75, that’s 56 hours and 45 minutes (0.75 × 60 = 45).
Why does the calculator show 0 whole days for a 30-hour span?
Because “whole days� means complete 24-hour periods. A 30-hour span contains one full day plus 6 hours, but the “whole days� output only counts the full 24-hour blocks, so it shows 1 day (since 30 ÷ 24 = 1.25, floor = 1). Wait — actually, 30 hours is 1.25 days, so whole days = 1. The calculator correctly shows 1. If you see 0, the span is less than 24 hours.
Related
Formula used
in start | Start date and time | - | 2025-01-01T09:00 | 0 in end | End date and time | - | 2025-01-03T17:30 | 0 out hours | Total hours | h | (end - start) / 3600000 | 2 out days | Whole days | d | floor((end - start) / 86400000) | 0 out minutes | Total minutes | min | (end - start) / 60000 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.