# Hours Calculator

This hours calculator computes the duration (in hours and minutes) between two times. It is useful for time sheet or time card calculations. To use the calculator, please provide two times and click the "Calculate" button. If the end time is earlier than the start time, the calculator will assume the end time is on the next day. The break deduction is optional.

## How to calculate hours and minutes between two times

Calculating the number of hours and minutes between two times can be achieved using the following algorithm; it is not the only way, but is a method that should work for most if not all cases:

- First determine the start and the end time. If the end time is "earlier" than the start time, such as a start time of 3 pm and an end time of 1 am, assume that the end time is on the following day (this is the assumption made by this calculator, and how to handle this case is discussed below, indicated by an *).
- Assuming the start and end times are not already in the format of a 24-hour clock, convert the times to 24-hour time.
- Times from 0:00 (12:00 AM) to 12:00 pm remain the same on a 24-hour clock.
- Times from 1:00 pm to 11 pm can be converted to 24-hour time by adding 12 to the corresponding time in the 12-hour format. For example, 1:00 pm is the same as 1 + 12 = 13:00 in 24-hour time. Also, times in the 24-hour format do not include the AM and PM since the times already make clear whether the time is in the morning or evening.

- If both start and end time involve 0 minutes (e.g. 13:00 and 22:00), then simply subtract the start time from the end time. The result is the number of hours between the two times. Otherwise, continue to the next step before performing subtraction.
- Convert the minutes portion of the time to a decimal by dividing the number of minutes by 60. This converts the number of minutes into hours in the form of a decimal. For example, to convert 15 minutes into an hour in decimal form:
15 minutes ÷ 60 = 0.25 hours
- Once all times have been converted to hours, subtract the start time from the end time. For example, given a start time of 13:00 and 22:15, convert 22:15 to 22.25, then subtract the start time:
22.25 - 13.00 = 9.25 hours
- If you do not need to deduct a break period, skip to step 8. If a break period needs to be deducted, convert the period to decimal hours if any minutes are involved, then subtract the break time from the number of hours found in step 5. For a break time of 45 minutes,
45 minutes ÷ 60 = 0.75 hours
- Subtract the break time from the solution found in step 5:
9.25 - 0.75 = 8.5 hours
- Convert the decimal portion of the hours back to minutes:
0.5 × 60 = 30 minutes

Thus, the time in hours and minutes between 13:00 and 22:15 after deducting a 45-minute break is 8 hours 30 minutes. If no break were included, the difference would have been 9.25 hours, or 9 hours 15 minutes.

*In cases where the calculation of time involves times that occur on different days (such that **end time < start time**), such as a start time of 13:45 and an end time of 1:15, the process is more or less the same except that we use the following formula:

duration between times = end time + 24 - start time

It is still necessary to convert the times to 24-hour time before using the above formula. 13:45 and 1:15 are written as 13.75 and 1.25 in decimal-hour form. Plugging these into the formula above yields:

duration between times = 1.25 + 24 - 13.75 = 11.5

Thus, there are 11.5 hours, or 11 hours 30 minutes between 13:45 and 1:15.