Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Time Duration Calculator (Elapsed Time Between Two Times or Dates)

Enter the start and end times. If the span crosses into another day, also enter the start and end dates (for times on the same day, you can leave the dates blank).

Enter the hour with AM or PM (5:30 PM is hour "5 PM", minute "30"). The 24-hour clock (hour "17") works too. The hours are required. Blank minutes and seconds count as 0. Fill in both dates or leave both blank. If the dates are blank and the end time is earlier than the start time, the start is treated as the day before (over midnight).
Result
Enter the start and end times (and the dates, if the span crosses into another day) in the fields on the left and press "Calculate". The result will appear here.

What you can do on this page

  • Enter two times, such as 8:30 to 17:30, and you get the elapsed time between them in hours, minutes and seconds (here, 9 h) right away
  • Add a start date and an end date, and spans that cross into other days, such as July 10 at 22:00 to July 12 at 6:30, are shown as "1 d 8 h 30 min" (leap years included)
  • The result also shows the same span as total hours (a decimal, such as 32.5 h), total minutes and total seconds
  • If the dates are blank and the end time is earlier than the start time, the start is treated as the day before, so spans over midnight work too
  • A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
Enter the hours with AM or PM, such as "8 AM" or "5 PM" (the 24-hour clock, such as "17", works too). To find hours worked minus a break, the related page "Work Hours Calculator" is more convenient.

What is this calculation used for?

Finding the travel time of an overnight bus or flight (travel)

An overnight bus that leaves at 10:00 PM and arrives at 6:30 the next morning takes \(23400 - 79200 + 86400 = 30600\) seconds = 8 hours 30 minutes, even though the date changes on the way.
Knowing the travel time makes a big difference when you estimate how long you can sleep on board or plan what to do after you arrive. Even when a schedule does not list the travel time, as with local lines or connections, you can work it out yourself from the departure and arrival times.

Tracking how long you sleep (health)

If you go to bed at 11:30 PM and get up at 6:15 AM, you slept 6 hours 45 minutes. Because the span goes over midnight, the calculation that treats the start as the day before (adding 86400 seconds) works as is.
Sleep time is one of the most basic health records. Write down when you go to bed and when you get up each day, and you can use this subtraction to find, for example, how many hours you slept on average this week.

Timing a marathon or race (sports)

A runner who starts a marathon at 9:00 and finishes at 13:57 has a time of 4 hours 57 minutes. Even if you forget your stopwatch, you can find the elapsed time by subtraction as long as you know the start and finish times.
Timing in track, swimming, cycling and other sports is exactly this: the difference between two times. Handling borrowing in base 60 for minutes and seconds correctly is the basis for comparing results accurately.

Logging study or project time (self-management)

If you study from 7:15 PM to 9:45 PM, that is 2 hours 30 minutes of study for the day. Write down the start and end times, and you can add up each day's total later with this same subtraction.
Study logs for an exam, time logs for remote work, and more: turning "from when to when" into "how many hours" is something you do almost every day.

Counting the time left until a deadline or event

"How many hours are there from 18:00 on July 10 until a 9:00 AM deadline on July 12?" With 2 days between the dates, \(86400 \times 2 + 32400 - 64800 = 140400\) seconds = 39 hours (1 day and 15 hours).
Thinking of the time left in hours makes a work plan much more realistic than a vague feeling of "I still have 2 days". Countdowns to a rocket launch or an exam are the same kind of time difference across dates.

Formula

Turning a time of day into seconds after midnight
Standard notation (the usual math form)
\(T\) \(=\) \(3600\) \(\times\) \(h\) \(+\) \(60\) \(\times\) \(m\) \(+\) \(s\)
In words (symbols replaced with words)
⑥ \(T\): time in seconds \(=\) ② \(3600\): seconds in 1 hour \(\times\) ① \(h\): hour \(+\) ④ \(60\): seconds in 1 minute \(\times\) ③ \(m\): minute \(+\) ⑤ \(s\): second
The formula in words
① Take the \(h\): hour
② and multiply it by \(3600\): seconds in 1 hour
③ add the \(m\): minute
④ multiplied by \(60\): seconds in 1 minute
⑤ add the \(s\): second
⑥ and you get the \(T\): time in seconds (how many seconds that time is after midnight)
Quick example
5:30 PM (17:30:00 on the 24-hour clock) in seconds is
time in seconds (63000) \(=\) seconds in 1 hour (3600) \(\times\) hour (17) \(+\) seconds in 1 minute (60) \(\times\) minute (30) \(+\) second (0)
\(T = 3600 \times 17 + 60 \times 30 + 0 = 61200 + 1800 = 63000\)
Key idea
If you try to work with times using three units at once (hours, minutes and seconds), it is easy to slip up when borrowing, because 60 seconds = 1 minute and 60 minutes = 1 hour. So this calculator first turns each time into one number: how many seconds after midnight it is. Once both times are in seconds, the rest is a plain subtraction. For PM times, add 12 to the hour to get the 24-hour clock before you calculate (5:30 PM → 17:30). The one exception is 12 PM (noon), which stays 12.
Time difference (subtracting in seconds)
Standard notation (the usual math form)
\(D\) \(=\) \(T_2\) \(-\) \(T_1\)
\(D\) \(=\) \(T_2\) \(-\) \(T_1\) \(+\) \(86400\)
In words (symbols replaced with words)
③ \(D\): elapsed time \(=\) ① \(T_2\): end time in seconds \(-\) ② \(T_1\): start time in seconds
\(D\): elapsed time \(=\) \(T_2\): end time in seconds \(-\) \(T_1\): start time in seconds \(+\) ④ \(86400\): seconds in 1 day
The formula in words
① Take the \(T_2\): end time in seconds
② subtract the \(T_1\): start time in seconds
③ and you get the \(D\): elapsed time (the number of seconds from start to end)
④ If you leave the dates blank and the end time is earlier than the start time (over midnight), the start is treated as the day before, so add the \(86400\): seconds in 1 day (the second formula)
Quick example
The elapsed time from 8:30:00 (30600 seconds) to 17:30:00 (63000 seconds) is
elapsed time (32400 s = 9 h) \(=\) end time (63000 s) \(-\) start time (30600 s)
\(D = 63000 - 30600 = 32400\)
\(32400 = 3600 \times 9\)
Key idea
The subtraction gives a negative number when the end time is the smaller number, as with a start at 23:45 and an end at 0:15 the next day. If you did not enter dates, this calculator assumes the start was on the day before (the span went over midnight) and adds one day, \(86400\) seconds (\(= 24 \times 3600\)). Example: from 23:45:30 to 0:15:10 the next day, \(910 - 85530 = -84620\), and \(-84620 + 86400 = 1780\) seconds = 29 min 40 s. If the start and end times are the same, the result is treated as "0 s" (not as 24 hours later).
Subtracting in hours and minutes by hand (borrowing 60)
Standard notation (the usual math form)
\(D\) \(=\) \(60\) \(\times\) \((h_2 - h_1)\) \(+\) \((m_2 - m_1)\)
In words (symbols replaced with words)
④ \(D\): elapsed time in minutes \(=\) ② \(60\): minutes in 1 hour \(\times\) ① \((h_2 - h_1)\): difference in hours \(+\) ③ \((m_2 - m_1)\): difference in minutes
The formula in words
① Take the \((h_2 - h_1)\): difference in hours
② multiply it by \(60\): minutes in 1 hour
③ add the \((m_2 - m_1)\): difference in minutes
④ and you get the \(D\): elapsed time in minutes (even if the difference in minutes is negative, just add it as it is and the answer is right)
Quick example
The elapsed time from 9:58 to 13:57 is
elapsed time (239 min = 3 h 59 min) \(=\) minutes in 1 hour (60) \(\times\) difference in hours (13 − 9) \(+\) difference in minutes (57 − 58)
\(D = 60 \times (13 - 9) + (57 - 58) = 240 - 1 = 239\)
\(239 = 60 \times 3 + 59\)
Key idea
If you subtract "13:57 − 9:58" by hand, the minutes give "57 − 58", which does not work. Just as with regrouping in ordinary subtraction, borrow 1 hour (\(= 60\) minutes) from the 13 hours and read the problem as "12 hours 117 minutes − 9 hours 58 minutes". Then the minutes are \(117 - 58 = 59\) and the hours are \(12 - 9 = 3\), so the answer is 3 hours 59 minutes. In ordinary subtraction you borrow 10, but time counts in groups of 60 (base 60), so you borrow 60. That is the only difference. The formula above does the same thing in one line by adding the difference in minutes even when it is negative.
Time difference across dates
Standard notation (the usual math form)
\(D\) \(=\) \(86400\) \(\times\) \(n\) \(+\) \(T_2\) \(-\) \(T_1\)
In words (symbols replaced with words)
⑤ \(D\): elapsed time \(=\) ② \(86400\): seconds in 1 day \(\times\) ① \(n\): days between the dates \(+\) ③ \(T_2\): end time in seconds \(-\) ④ \(T_1\): start time in seconds
The formula in words
① Take the \(n\): days between the dates (counted on the calendar from the start date to the end date)
② multiply it by \(86400\): seconds in 1 day
③ add the \(T_2\): end time in seconds
④ subtract the \(T_1\): start time in seconds
⑤ and you get the \(D\): elapsed time
Quick example
The elapsed time from 22:00 on July 10, 2026 to 6:30 on July 12, 2026 (2 days apart on the calendar) is
elapsed time (117000 s = 32 h 30 min) \(=\) seconds in 1 day (86400) \(\times\) days between the dates (2) \(+\) end time (23400 s) \(-\) start time (79200 s)
\(D = 86400 \times 2 + 23400 - 79200 = 117000\)
\(117000 = 86400 \times 1 + 3600 \times 8 + 60 \times 30\)
Key idea
The days between the dates, \(n\), counts only the dates on the calendar (July 10 → July 12 is 2 days, and February 29 in a leap year is counted correctly). The formula just adds "the seconds in \(n\) whole days" to "the difference between the two times of day", so even if the difference between the times (\(T_2 - T_1\)) is negative, adding and subtracting as written gives the right answer. If the result is 1 day or more, you can also count every \(86400\) seconds as 1 day and write it as "1 d 8 h 30 min".
The basic method for a time difference is: turn each time into seconds after midnight, then subtract. If you enter no dates and the end is earlier than the start, add one day, 86400 seconds. If the span crosses dates, add the days between the dates × 86400 seconds.

Symbols and terms

Symbols

\(h\), \(m\), \(s\) h, m, s The hour (\(h\)), minute (\(m\)) and second (\(s\)) of a time of day, on the 24-hour clock (example: for 5:30 PM, \(h = 17\), \(m = 30\) and \(s = 0\)). They stand for "hour", "minute" and "second".
\(T\) T A time of day turned into seconds after midnight, found with \(T = 3600h + 60m + s\). (Example - 17:30:00 → 63000 seconds)
\(T_1\), \(T_2\) T sub 1, T sub 2 The start time in seconds (\(T_1\)) and the end time in seconds (\(T_2\)). (Example - 8:30:00 → \(T_1 = 30600\), 17:30:00 → \(T_2 = 63000\))
\(h_1, m_1\), \(h_2, m_2\) h sub 1, m sub 1, h sub 2, m sub 2 The hour and minute of the start time (subscript 1) and of the end time (subscript 2), used in the subtract-by-hand formula.
\(D\) D The elapsed time (how long it is from start to end). D stands for "duration". The calculator on this page finds it in seconds first, then shows it as "9 h" or "3 h 59 min".
\(n\) n The number of days from the start date to the end date, counting only the dates on the calendar. (Example - July 10 → July 12 gives \(n = 2\))
\(3600\), \(86400\) three thousand six hundred, eighty-six thousand four hundred The seconds in 1 hour (\(60 \times 60 = 3600\)) and the seconds in 1 day (\(24 \times 3600 = 86400\)).

Terms

time of day A point in time, such as 8:30. It is different from a length of time, such as 9 hours. This page finds the length of time between two times of day (the elapsed time).
length of time How long something lasts, such as 9 hours. It is different from a time of day, such as 8:30. This page finds the length of time between two times of day (the elapsed time).
elapsed time The length of time that passes from the start time to the end time. It is the answer this page finds.
24-hour clock A way of writing times of day with hours from 0 to 23, sometimes called military time in the US. Add 12 to PM hours (5:30 PM → 17:30, 10:00 PM → 22:00). Midnight is 0:00, and noon stays 12:00.
base 60 Counting in groups of 60, where 60 of one unit make 1 of the next unit up. Sixty seconds make 1 minute and 60 minutes make 1 hour. It is easy to make mistakes when this is mixed with ordinary base 10, so this calculator first puts everything into seconds.
borrowing In subtraction, taking 1 from the next place up when a place is too small to subtract from (also called regrouping). When you subtract times by hand, you borrow 60 instead of 10 (1 hour = 60 minutes, 1 minute = 60 seconds).
over midnight When the date changes between the start and the end, as with an overnight bus or a night shift. If you calculate without dates, the end time is a smaller number than the start time, so the start is treated as the day before and one day, 86400 seconds, is added. (When you enter dates, the days between the dates are used instead.)
leap year A year with a February 29 (about once every 4 years). When you count the days between two dates, a span that includes February 29 has one more day. This calculator counts it correctly, just as on the calendar.

Good to know before you start

Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back over these topics is the fastest way forward.

Time of day and elapsed time (Grades 2–3)
  • Knowing the difference between a time of day (a point in time, such as 8:30) and a length of time (such as 9 hours)
  • Knowing that 1 minute = 60 seconds, 1 hour = 60 minutes and 1 day = 24 hours
AM, PM and the 24-hour clock (Grades 2–3)
  • Knowing that adding 12 to a PM hour gives the 24-hour clock (5:30 PM → 17:30)
  • Knowing that midnight is the start of the day and is written 0:00 on the 24-hour clock
Subtraction with borrowing (Grades 2–3)
  • Being able to borrow from the next place up when a place is too small to subtract from
  • Knowing that you borrow 60, not 10, when you subtract times by hand (1 hour = 60 minutes, 1 minute = 60 seconds)
Division with remainders (Grades 4–5)
  • Being able to find a quotient and remainder, such as 239 ÷ 60 = 3 R 59, to turn minutes back into hours and minutes
  • Being able to divide large numbers (such as 117000) while keeping track of place value
Decimals (Grades 4–5)
  • Knowing that 0.5 means one half, and telling apart minutes (base 60) and decimals (base 10), as in 30 minutes = 0.5 hours
  • Being able to read the result of a division such as 117000 ÷ 3600 = 32.5 as a decimal

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to turn a time into seconds after midnight
Hour (24-hour clock) 17
Minute 30
Second 0
Time in seconds =B1*3600+B2*60+B3
Table for the time difference on the same day (works over midnight)
Start: hour (24-hour clock) 8
Start: minute 30
Start: second 0
End: hour (24-hour clock) 17
End: minute 30
End: second 0
Start in seconds =B1*3600+B2*60+B3
End in seconds =B4*3600+B5*60+B6
Elapsed time (s) =IF(B8<B7,B8-B7+86400,B8-B7)
Elapsed: hours =QUOTIENT(B9,3600)
Elapsed: minutes =QUOTIENT(MOD(B9,3600),60)
Elapsed: seconds =MOD(B9,60)
Table for a time difference across dates (serial values)
Start date and time =DATE(2026,7,10)+TIME(22,0,0)
End date and time =DATE(2026,7,12)+TIME(6,30,0)
Elapsed (difference in serial values = days) =B2-B1
Elapsed time shown as h:mm:ss =TEXT(B2-B1,"[h]:mm:ss")
Total hours (decimal) =(B2-B1)*24
In the first table, enter the hour, minute and second of a time in B1 to B3, and B4 shows the seconds after midnight (63000 in this example).
In the second table, enter the start and end times in B1 to B6. B7 and B8 turn them into seconds (30600 and 63000), and B9 shows the elapsed time in seconds (32400). The IF function adds 86400 when the end is the smaller number, to handle spans over midnight. B10 to B12 split the seconds into hours, minutes and seconds with QUOTIENT (the whole-number part of a division) and MOD (the remainder). The answer is 9 hours 0 minutes 0 seconds.
The third table works across dates. When you build a date and time with the DATE and TIME functions, Excel stores it as a serial value (1 day = 1), so the subtraction in B3 alone gives the elapsed time as a decimal number of days (about 1.3542 days). The TEXT format "[h]:mm:ss" in B4 keeps counting hours past 24, so it shows "32:30:00", and B5 multiplies the serial value by 24 to get 32.5 total hours. Just replace the values in column B with your own.

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to turn a time into seconds after midnight
Hour (24-hour clock) 17
Minute 30
Second 0
Time in seconds =B1*3600+B2*60+B3
Table for the time difference on the same day (works over midnight)
Start: hour (24-hour clock) 8
Start: minute 30
Start: second 0
End: hour (24-hour clock) 17
End: minute 30
End: second 0
Start in seconds =B1*3600+B2*60+B3
End in seconds =B4*3600+B5*60+B6
Elapsed time (s) =IF(B8<B7,B8-B7+86400,B8-B7)
Elapsed: hours =QUOTIENT(B9,3600)
Elapsed: minutes =QUOTIENT(MOD(B9,3600),60)
Elapsed: seconds =MOD(B9,60)
Table for a time difference across dates (serial values)
Start date and time =DATE(2026,7,10)+TIME(22,0,0)
End date and time =DATE(2026,7,12)+TIME(6,30,0)
Elapsed (difference in serial values = days) =B2-B1
Elapsed time shown as h:mm:ss =TEXT(B2-B1,"[h]:mm:ss")
Total hours (decimal) =(B2-B1)*24
IF (a condition), QUOTIENT (the whole-number part of a division), MOD (the remainder), DATE, TIME and TEXT are written the same way in Google Sheets as in Excel. Copy the whole table, paste it into cell A1, and replace the values in column B with your own. The answers are the same as in Excel.

How to calculate it in Python

from datetime import datetime

# Start and end date and time (use the same date if the span does not cross into another day)
start = datetime(2026, 7, 10, 22, 0, 0)   # July 10, 2026, 22:00:00
end = datetime(2026, 7, 12, 6, 30, 0)     # July 12, 2026, 6:30:00

duration = end - start                          # elapsed time (a timedelta)
total_seconds = int(duration.total_seconds())   # total seconds

hours, remainder = divmod(total_seconds, 3600)  # hours and the seconds left over
minutes, seconds = divmod(remainder, 60)        # split the rest into minutes and seconds
days, day_remainder = divmod(total_seconds, 86400)  # for the display with days

print(f"Elapsed time: {hours} h {minutes} min {seconds} s")
print(f"With days: {days} d {day_remainder // 3600} h {day_remainder % 3600 // 60} min")
print(f"Total hours: {total_seconds / 3600} h")
print(f"Total minutes: {total_seconds / 60} min")
print(f"Total seconds: {total_seconds} s")
Runs with the standard library only. Subtracting one datetime from another gives the elapsed time as a timedelta, and total_seconds() turns it into seconds. divmod returns the quotient and the remainder of a division at the same time: dividing the seconds by 3600 gives the hours and the rest, and dividing by 60 gives minutes and seconds. Change the start and end date and time at the top (in the order year, month, day, hour, minute, second), then run the code.

How to write it in LaTeX and other math languages (copy and paste)

Turning a time of day into seconds after midnight
T = 3600h + 60m + s
T = 3600h + 60m + s
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>T</mi><mo>=</mo>
    <mn>3600</mn><mi>h</mi>
    <mo>+</mo><mn>60</mn><mi>m</mi>
    <mo>+</mo><mi>s</mi>
  </mrow>
</math>
T = 3600h + 60m + s
totalSeconds = 3600*h + 60*m + s
T := 3600*h + 60*m + s;
T = 3600*h + 60*m + s;
T = 3600h + 60m + s
Time difference (subtracting in seconds)
D = T₂ − T₁  (T₂ ≥ T₁),  D = T₂ − T₁ + 86400  (T₂ < T₁)
D = T_2 - T_1 \quad (T_2 \ge T_1), \qquad D = T_2 - T_1 + 86400 \quad (T_2 < T_1)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>D</mi><mo>=</mo>
    <msub><mi>T</mi><mn>2</mn></msub><mo>&#x2212;</mo>
    <msub><mi>T</mi><mn>1</mn></msub>
    <mo>,</mo><mspace width="0.7em"/>
    <mi>D</mi><mo>=</mo>
    <msub><mi>T</mi><mn>2</mn></msub><mo>&#x2212;</mo>
    <msub><mi>T</mi><mn>1</mn></msub>
    <mo>+</mo><mn>86400</mn>
  </mrow>
</math>
D = T_2 - T_1, D = T_2 - T_1 + 86400
durationSeconds = If[t2 >= t1, t2 - t1, t2 - t1 + 86400]
dur := `if`(t2 >= t1, t2 - t1, t2 - t1 + 86400);  # D is reserved in Maple (the differential operator), so the name dur is used
if t2 >= t1, D = t2 - t1; else, D = t2 - t1 + 86400; end
D = T_2 - T_1 (T_2 ≥ T_1), D = T_2 - T_1 + 86400 (T_2 < T_1)
Subtracting in hours and minutes by hand (borrowing 60)
D = 60(h₂ − h₁) + (m₂ − m₁)
D = 60(h_2 - h_1) + (m_2 - m_1)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>D</mi><mo>=</mo>
    <mn>60</mn>
    <mo>(</mo><msub><mi>h</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>h</mi><mn>1</mn></msub><mo>)</mo>
    <mo>+</mo>
    <mo>(</mo><msub><mi>m</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>m</mi><mn>1</mn></msub><mo>)</mo>
  </mrow>
</math>
D = 60(h_2 - h_1) + (m_2 - m_1)
durationMinutes = 60*(h2 - h1) + (m2 - m1)
dur := 60*(h2 - h1) + (m2 - m1);  # D is reserved in Maple (the differential operator), so the name dur is used
D = 60*(h2 - h1) + (m2 - m1);
D = 60(h_2 - h_1) + (m_2 - m_1)
Time difference across dates
D = 86400n + T₂ − T₁
D = 86400n + T_2 - T_1
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>D</mi><mo>=</mo>
    <mn>86400</mn><mi>n</mi>
    <mo>+</mo><msub><mi>T</mi><mn>2</mn></msub>
    <mo>&#x2212;</mo><msub><mi>T</mi><mn>1</mn></msub>
  </mrow>
</math>
D = 86400n + T_2 - T_1
durationSeconds = 86400*n + t2 - t1
dur := 86400*n + T2 - T1;  # D is reserved in Maple (the differential operator), so the name dur is used
D = 86400*n + T2 - T1;
D = 86400n + T_2 - T_1

How to have ChatGPT  do the calculation

You are a time calculation assistant. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing).

The start is July 10, 2026 at 22:00:00 and the end is July 12, 2026 at 6:30:00 (both on the 24-hour clock).
Find each of the following:
1. The elapsed time (in the form "X hours Y minutes Z seconds")
2. The elapsed time with days (in the form "X days Y hours Z minutes")
3. The total hours (as a decimal), total minutes and total seconds

Find the elapsed time by subtracting Python datetime objects, and split it into hours, minutes and seconds with divmod.
Show the formulas you used and the numbers from the execution result.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.