时间跨度计算器 — 两个时间之间的小时、分钟 & 秒
This time duration calculator finds the exact number of hours, minutes, and seconds between any two clock times. Enter a start time and an end time — overnight and cross-midnight periods are handled automatically. Results are shown in HH:MM:SS format, as decimal hours, and as total minutes and seconds, making it ideal for payroll, billing, shift scheduling, and time tracking.
Calculate Time Between Two Times
Enter a start time and end time to calculate the exact duration in hours, minutes, and seconds. Cross-midnight durations are detected automatically.
Duration (HH:MM:SS)
08:00:00
Decimal Hours
8.0000
Total Minutes
480
Total Seconds
28,800
Frequently Asked Questions
时间段计算器是如何工作的?
时间段计算器计算两个日期时间点之间的精确时间段,结果分解为年、月、日、小时、分钟和秒。例如,从 2023 年 1 月 1 日到 2024 年 6 月 15 日之间有 1 年 5 个月 14 天。
如何计算工作时长或项目时长?
输入项目开始日期时间和结束日期时间,计算器会给出总时长的精确分解(年、月、日、小时等)和总小时数。这对于计算合同工时、项目周期统计、学习或健身时间追踪非常实用。
时间段计算如何处理不同月份的天数?
月份的天数不同(28-31 天)使时间段计算复杂化。本计算器使用实际日历计算,精确处理大小月和闰年(2 月 29 日)。例如,1 月 31 日加 1 个月 = 2 月 28/29 日(视闰年而定)。
如何追踪多个时间段并求总计?
本计算器支持添加多个时间段并汇总。例如,追踪一个月内在不同项目上的工时:输入每个项目的开始和结束时间,计算器会自动计算每段工时并给出总计,方便开具发票或计算工资。
How to Calculate Time Duration
Duration Formula
The time duration between two clock times is calculated by converting each time to total seconds since midnight, then subtracting:
startSeconds = startHour × 3600 + startMinute × 60 + startSecond
endSeconds = endHour × 3600 + endMinute × 60 + endSecond
totalSeconds = endSeconds − startSeconds
hours = floor(totalSeconds / 3600)
minutes = floor((totalSeconds mod 3600) / 60)
seconds = totalSeconds mod 60
Example: From 09:30:15 to 14:45:30. Start = 9 × 3600 + 30 × 60 + 15 = 34,215 s. End = 14 × 3600 + 45 × 60 + 30 = 53,130 s. Total = 53,130 − 34,215 = 18,915 s. Result: 5 h 15 m 15 s → 05:15:15.
To convert the total duration to decimal hours, divide the total seconds by 3,600. For example, 5 hours and 30 minutes equals 5.5 decimal hours (19,800 ÷ 3,600 = 5.5).
Cross-Midnight Handling
When the end time is earlier than the start time (for example, start 22:00 and end 06:30), the calculator automatically assumes the period spans across midnight. It adds 24 hours (86,400 seconds) to the end time before subtracting:
if endSeconds < startSeconds:
endSeconds += 86400 # add 24 hours
totalSeconds = endSeconds − startSeconds
Example:Night shift from 22:00 to 06:30. End (23,400 s) < Start (79,200 s), so add 86,400: endSeconds = 109,800. Total = 109,800 − 79,200 = 30,600 s = 8 hours 30 minutes.
This approach works for any shift or period spanning midnight but assumes the gap is less than 24 hours. For durations across multiple days, add the individual day segments.
Common Duration Reference Table
Here are frequently used work shifts and activity durations for quick reference:
| Scenario | Start | End | Duration | Decimal Hours |
|---|---|---|---|---|
| Standard workday | 09:00 | 17:00 | 08:00:00 | 8.0000 |
| Half day | 09:00 | 13:00 | 04:00:00 | 4.0000 |
| Night shift | 22:00 | 06:00 | 08:00:00 | 8.0000 |
| Lunch break | 12:00 | 13:00 | 01:00:00 | 1.0000 |
| Feature film | 19:30 | 21:48 | 02:18:00 | 2.3000 |
| Marathon (avg) | 07:00 | 11:30 | 04:30:00 | 4.5000 |
| Overnight flight | 23:45 | 07:15 | 07:30:00 | 7.5000 |
| Full day (midnight to midnight) | 00:00 | 23:59:59 | 23:59:59 | 23.9997 |
Decimal hours are commonly used in payroll, billing, and time-tracking systems.