ThisCalculator

Date and time

Hours Calculator Between Two Times: How to Use

Updated · Standard formula, shown below

Duration 8:00:00 h:mm
Duration (decimal)
8.00 hours
Result
Start time (HH:MM)
540
You entered
End time (HH:MM)
1020
You entered

Hours Calculator Between Two Times: How to Use

This calculator works out the exact number of hours (and minutes) between any two times of day, on the same day or across midnight. You enter a start time and an end time, and it returns the duration in hours and minutes, plus the same duration expressed in decimal hours. The result is the actual elapsed time, not a rounded estimate.

Formula

The calculation is straightforward once both times are converted to minutes after midnight. Let:

  • t = start time in minutes after midnight (e.g., 9:00 AM = 540)
  • u = end time in minutes after midnight (e.g., 5:00 PM = 1020)

The duration in minutes is:

Duration = (u − t + 1440) mod 1440

The mod 1440 step handles the case where the end time is earlier than the start time, meaning the interval crosses midnight. Adding 1440 (the number of minutes in a day) before the modulo ensures the result is always a positive number between 0 and 1439. To get decimal hours, divide the duration in minutes by 60.

Worked Example

Using the default values from the calculator above: start at 9:00 AM and end at 5:00 PM.

  1. Convert start: 9:00 AM = 9 × 60 = 540 minutes
  2. Convert end: 5:00 PM = 17 × 60 = 1020 minutes
  3. Subtract: 1020 − 540 = 480 minutes
  4. Since 480 is non-negative, no midnight adjustment is needed.
  5. Duration = 480 minutes = 8 hours exactly.
  6. Decimal hours = 480 / 60 = 8.00 hours

The calculator shows 8:00 as the duration and 8.00 as the decimal hours.

When to Use This Calculator

You need this calculation whenever you must know the precise length of an interval defined by two clock times. Common situations include:

  • Calculating work hours for a timesheet (e.g., 9:00 AM to 5:30 PM)
  • Figuring out how long a meeting or event lasted
  • Determining sleep duration from bedtime to wake-up time
  • Computing travel time between a departure and arrival time
  • Measuring the duration of a shift that starts at night and ends the next morning

The calculator assumes both times are on a 24-hour clock or that you correctly indicate AM/PM. If you enter 9:00 and 5:00 without specifying AM/PM, the calculator treats them as 9:00 and 5:00 on a 24-hour scale, which would give a negative result before the modulo – effectively 20 hours. Always use 24-hour format (e.g., 17:00 instead of 5:00 PM) to avoid ambiguity.

How to Read the Result

The primary output is a duration in hours and minutes, formatted as H:MM. For example, 8:30 means 8 hours and 30 minutes, not 8:30 AM. The secondary output is the same duration in decimal hours (e.g., 8.50), which is useful for payroll calculations where hours are often expressed as decimals (8.5 hours instead of 8:30).

If the start and end times are identical, the result is 0:00 – the calculator does not assume a full 24-hour day. If you need the duration across multiple days (e.g., from Monday 9 AM to Wednesday 5 PM), this calculator only handles a single day span; you would need to add full days separately.

Common Mistakes and Misconceptions

A frequent error is forgetting to convert AM/PM to 24-hour time. For example, entering 3:00 for both start and end will give 0:00, but if you meant 3:00 PM to 3:00 AM, the true duration is 12 hours. Always use 24-hour format to avoid this.

Another mistake is mixing units. Some people subtract 9 from 5 and get 4, forgetting that 5 PM is 17:00 in 24-hour time. The correct difference is 17 − 9 = 8 hours.

A common misconception is that the modulo operation “adds a day� automatically. It does not add a day; it simply wraps the result to a positive value within 0–24 hours. For intervals longer than 24 hours, the calculator will not show the extra days – it only shows the remainder. For example, from Monday 9 AM to Tuesday 5 PM is 32 hours, but the calculator would show 8:00 because it only measures the time past midnight on the second day.

Time Formats and Units

The calculator uses minutes after midnight internally. This is a standard approach because it avoids the complexity of base-60 arithmetic. The inputs are given in hours and minutes (HH:MM), but the formula converts them to pure minutes. The output is then converted back to hours and minutes for display.

If you prefer to work with decimal hours, you can enter times as decimal hours (e.g., 9.5 for 9:30) directly in the input fields, since the calculator treats the input as minutes after midnight. However, the display will still show the result in H:MM format. For most people, entering HH:MM is more intuitive.

Limitations of the Formula

This formula assumes a fixed 24-hour day with no daylight saving time adjustments. If the interval crosses a DST transition, the actual elapsed time may be 23 or 25 hours, but the calculator will still show the nominal 24-hour difference. For payroll or legal purposes, you should verify whether DST affects your specific date range.

The formula also does not account for time zones. If you are calculating the duration between two times in different time zones, you must first convert both to the same time zone (typically UTC) before subtracting. This calculator is only for two times in the same time zone.

Finally, the result is always rounded to the nearest minute (or to two decimal places for decimal hours). If you need seconds or milliseconds, you would need a more precise tool that accepts seconds as input.

Frequently Asked Questions

How do I calculate hours between two times across midnight?

Enter both times in 24-hour format, even if the end time is numerically smaller than the start time. The calculator automatically adds 24 hours to the end time when needed, so 22:00 to 06:00 gives 8:00 hours correctly.

What is the difference between 8:00 and 8.0 hours?

8:00 is a duration in hours and minutes – exactly 8 hours and 0 minutes. 8.0 is the same duration expressed as a decimal number of hours. They are equal; the decimal form is often used in payroll (8.0 hours) while the colon form is used on time sheets (8:00).

Why does my result show 0:00 when I enter the same time twice?

Because the calculator measures elapsed time, not a full day. If you start and end at the same time, zero minutes have passed. If you want to represent a full 24-hour period, you would enter the start time and then the same time on the next day – but this calculator only handles a single day, so you would need to add 24 hours manually.

Can I use this for calculating work hours including breaks?

This calculator gives the total elapsed time between start and end. To get paid work hours, you must subtract any unpaid break time separately. For example, if you work 9:00 to 17:00 with a 30-minute lunch, the calculator shows 8:00, but your paid hours are 7:30.

Does the calculator handle seconds?

No, it only accepts hours and minutes. If you need seconds, convert them to minutes first (e.g., 15 seconds = 0.25 minutes) and add to the minute value. The result will be rounded to the nearest minute.

What if I enter a time after 23:59?

The calculator does not validate input beyond 24 hours. Entering 25:00 would be treated as 25 hours after midnight, which is effectively 1:00 AM the next day. For clarity, always use times between 00:00 and 23:59.

Related

Formula used
in t | Start time (HH:MM) | - | 540 | 0
in u | End time (HH:MM) | - | 1020 | 0
out h | Duration | h:mm | (u - t + 1440) % 1440 | time
out d | Duration (decimal) | hours | ((u - t + 1440) % 1440) / 60 | 2

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.