2026-05-16 · 8 min read
How to Calculate Time Differences Across Dates, Hours, and Time Zones
A practical walkthrough of time subtraction, why naive arithmetic fails across midnight and DST boundaries, and how to get accurate results every time.
James Whitfield
Founder & Lead Editor
Why Time Subtraction Is Harder Than It Looks
Subtracting one time from another seems like basic arithmetic: if a meeting starts at 2:30 PM and ends at 4:15 PM, the duration is 1 hour and 45 minutes. The calculation is straightforward when both times are on the same day, in the same time zone, and do not cross any daylight saving boundary. Remove any one of those conditions and the simple approach breaks.
Time calculations that span midnight, cross time zones, or fall near a daylight saving transition require a more systematic approach. Getting them wrong is common and consequential — miscalculated durations affect payroll, project billing, SLA compliance, and logistics planning in ways that are hard to catch until something goes wrong.
Same-Day Duration: The Simple Case
For same-day durations within a single time zone, the calculation is: convert both times to a common unit (minutes past midnight works well), subtract, then convert the result back to hours and minutes.
2:30 PM = 870 minutes past midnight. 4:15 PM = 975 minutes past midnight. 975 - 870 = 105 minutes = 1 hour 45 minutes.
In decimal hours (useful for payroll), divide the minute count by 60: 105 / 60 = 1.75 hours. This is the format most payroll systems expect and the format on most time invoices.
Crossing Midnight
When a work period crosses midnight — common in overnight shifts, international calls, and manufacturing operations — naive subtraction produces a negative number. An overnight shift that starts at 10:00 PM and ends at 6:00 AM is 8 hours long, but 6:00 AM minus 10:00 PM gives -16 hours if you are simply subtracting.
The correct approach: add 24 hours to the end time when it is earlier in the clock than the start time. 6:00 AM becomes 30:00 (6:00 AM the next day in 24-hour notation). 30:00 - 22:00 = 8 hours.
For durations spanning more than one midnight — a 40-hour work week, a multi-day project — convert everything to a reference timestamp before subtracting. The cleanest reference is UTC seconds (Unix timestamp). Subtract the start timestamp from the end timestamp and convert the difference back to hours, minutes, and seconds.
Cross-Time Zone Duration
If two events happen in different time zones, the duration between them requires converting one or both times to a common reference before subtracting. UTC is the universal choice.
Example: A shipment departs from Tokyo at 3:00 PM JST (UTC+9) and arrives in London at 6:00 AM GMT (UTC+0) the next day. Departure in UTC: 3:00 PM JST = 6:00 AM UTC. Arrival in UTC: 6:00 AM GMT = 6:00 AM UTC the next day. Duration: 24 hours.
The trap: calculating this "locally" gives Tokyo time of 3:00 PM departure and a local arrival time that is meaningless in Tokyo terms. Any cross-zone duration must be calculated in UTC to be correct.
The Daylight Saving Complication
Daylight saving transitions add or remove an hour from the clock at a specific moment. This means that durations spanning a DST transition are not what naive arithmetic suggests.
In a spring-forward transition (clocks jump from 2:00 AM to 3:00 AM), an event starting at 1:00 AM and ending at 4:00 AM lasts only 2 hours in wall time, not 3. The hour from 2:00 to 3:00 does not exist in the local clock on that date.
In a fall-back transition (clocks fall from 2:00 AM back to 1:00 AM), the hour from 1:00 AM to 2:00 AM occurs twice. An event starting at 12:30 AM and ending at 2:30 AM might last 2 hours or 3 hours depending on which 1:00 AM you started in.
For payroll and legal purposes, DST transitions require explicit handling. Most payroll systems use local wall clock time for shift starts and ends, and the system needs to know that the "extra hour" in a fall-back shift is actually worked time. A shift record that simply shows 12:00 AM to 3:00 AM is ambiguous without knowing whether DST was in effect.
Calculating Duration in Days, Hours, and Minutes
For multi-day durations, express the total difference in hours first, then break it into days and remaining hours.
Total hours from January 5 at 8:00 AM to January 7 at 2:30 PM: from Jan 5 8:00 AM to Jan 7 8:00 AM is exactly 48 hours. From 8:00 AM to 2:30 PM on Jan 7 is 6 hours 30 minutes. Total: 54 hours 30 minutes = 2 days 6 hours 30 minutes.
In many contexts (project management, billing, SLA) it is cleaner to express the duration entirely in hours (54.5 hours) rather than splitting into days, because "days" creates ambiguity — business days, calendar days, and 24-hour periods are all called "days" in different contexts.
Useful Patterns for Different Contexts
Payroll and billing
Express all durations in decimal hours. Round to the nearest 6 minutes (0.1 hour) for invoicing. Track daily totals separately before summing to a weekly total — this preserves the audit trail and makes it easy to check overtime thresholds.
Project management
Express duration in business hours (excluding weekends and holidays) or calendar hours depending on whether the project operates on business days or continuously. Always specify which convention you are using when reporting duration to stakeholders.
SLA and support tickets
Many SLA agreements define response time in business hours. A ticket opened at 4:30 PM Friday with a 4-business-hour SLA is not due at 8:30 PM Friday — it is due at 10:30 AM Monday (2:30 PM Friday remaining in business hours + 4:00 hours of next business day). Correctly calculating SLA deadlines requires knowing the business hours window and holiday schedule.
When to Use a Calculator Instead of Mental Math
Simple same-day durations without time zone or DST complications are easy to do mentally or on paper. Any calculation that involves two or more of the following should use a dedicated time difference calculator rather than manual arithmetic: different dates, different time zones, potential DST transitions, required decimal output, or business-hours filtering.
The cost of an error in these cases — a misbilled invoice, a missed SLA, an incorrect payroll calculation — far exceeds the 30 seconds it takes to use a calculator. Treat time calculations in professional contexts the same way you would treat financial calculations: verify them with a tool, do not rely on mental arithmetic alone.