Add and subtract durations with the sign kept, so one hour minus two hours is minus one hour. Also moves a time of day forward or back and says how many midnights it crossed.
Initializing in your browser…
Exact ages and date differences worked out on the calendar itself, with no arithmetic on milliseconds, so the answer is the same in every time zone. Shows which days are not 86,400 seconds long.
Aspect ratios reduced exactly by the greatest common divisor, with the reduction multiplied back as a check, resizes that say whether they are exact, and named ratios that carry a note where the name is not the ratio.
Exact arithmetic on rationals, with both evaluation conventions named and the precedence table the parser runs on printed on the page.
One hour minus two hours. Two operations, Subtract and Difference, are on the page. What do they print?
Input
01:00:00 subtract 02:00:00
Result
Subtract: -01:00:00 Difference: 01:00:00
They are different questions and they now have different answers. The shipped version of this tool split the total with Math.abs before formatting it, so both printed 01:00:00 and there was no way to tell the two operations apart from their output for any pair of inputs at all. Subtraction keeps its sign here, and when the result is negative the page says which operation you probably wanted. Every field is read as a whole number too, so "1.5" hours is refused by name rather than truncated to 1 the way parseInt does it, and 90 minutes carries into an hour and a half.
Add and subtract lengths of time. One hour minus two hours is minus one hour, and the answer says so, which is the thing most time calculators get wrong by taking an absolute value before printing.
A duration can be negative and a time of day cannot, and a tool that runs both through the same code has to lose something. Here they are two modes.
**The sign is part of the answer.** The shipped version of this tool split the total with `Math.abs` before formatting it, so one hour minus two hours printed as 01:00:00, and Subtract and Difference produced the identical string for every pair of inputs there is. There was no way to tell the two operations apart from their output. Subtract keeps the sign now; Difference is how far apart two lengths are and is never negative; and when the result is negative the page says which one you probably wanted.
**Every field is read as a whole number, and a value it cannot read is refused by name.** `parseInt` truncates: 1.5 hours becomes 1, losing half an hour silently, and 1e3 becomes 1. Neither happens. A value past its usual range still carries, because 90 minutes is an hour and a half and is a perfectly ordinary thing to type; only something that is not a whole number is refused, with a message naming it.
**The answer follows the inputs.** There is no Calculate button, because a button leaves a stale answer on the screen the moment you change a field, and that is the state a screenshot gets taken in.
**A time of day is a separate mode.** It reads both the 24 hour and the 12 hour form, where 12:00 AM is midnight and 12:00 PM is noon, which is the pair every hand-rolled parser gets backwards. Moving a clock forward or back reports how many midnights it crossed. It says plainly that this is arithmetic on a clock face and not an instant in a time zone, so it makes no claim about a daylight saving change; that needs a date and a zone, which the unix timestamp converter has.
Alongside the result: the same length written in weeks, days, hours, minutes and seconds with the exact ones marked, the total in seconds, and the note that a day here is 86,400 seconds, which is the right answer for a duration and the wrong one for a calendar day.
Subtract gives -01:00:00. Difference gives 01:00:00. Those are different answers to different questions, and a calculator that prints 01:00:00 for both has thrown away the sign.
Enter 0 hours and 90 minutes. It carries to 01:30:00, and the unit panel shows 1.5000 hours marked as exact.
In Time of day mode this gives 03:15:00, and the page says it crossed one midnight, so it is the next day.
With the total in seconds and in decimal hours for a payroll form.
Difference, which is never negative, sitting next to Subtract, which is.
Time of day mode, which says whether it runs past midnight.
Because Time 2 is longer than Time 1 and you asked for Subtract, which keeps the order. If you want how far apart they are, choose Difference. A calculator that shows a positive number for both has taken an absolute value and told you nothing about which is which.
Yes. Values past their usual range carry, so 90 minutes becomes an hour and a half. What is refused is a value that is not a whole number, because reading 1.5 as 1 loses half an hour without saying anything.
No, and it says so. This is arithmetic on durations and on a clock face. A clock change is a property of a date in a particular zone, so it needs both; the unix timestamp converter and the date and age calculator handle that side.
Midnight. 12:00 PM is noon. That pair is the one hand-rolled twelve hour parsers usually get backwards, and it is tested here.
Because the answer is a pure function of the inputs, so it can just follow them. A button means that changing a field leaves the previous answer on the screen, which is exactly when somebody reads the wrong number.
Every calculation runs locally in your browser. Your numbers and expressions are not transmitted or stored.