Files
freeCodeCamp/guide/english/mathematics/adding-and-subtracting-time/index.md
ggbong734 ffb7b0eea6 Content update and format improvement (#28840)
* Content update and format improvement

Simplified the content, added subheadings, and formatted the examples.

* Update index.md
2019-07-02 18:16:25 -07:00

2.3 KiB

title
title
Adding and Subtracting Time

Adding and Subtracting Time

There are a few basic rules that guide addition and subtraction of time.

Here they are:

  • 60 seconds make 1 minute
  • 60 minutes make 1 hour
  • 24 hours make 1 day
  • 7 days make 1 week
  • 52 weeks make 1 year
  • 365 days make 1 year
  • 366 days make 1 leap year
  • 12 calendar months or 13 lunar months make 1 year

Adding

Let us see an addition example below by adding Line 1 to Line 2:

   Line 1: 3hr 45min 20sec
   Line 2: 2hr 20min 50sec
           --------
           5hr 65min 70sec  (convert 60 seconds to a minute)
           --------
           5hr 66min 10sec  (convert 60 minutes to an hour)
           --------
           6hr 06min 10sec  (final answer)

First, we perform the addition for each time period (seconds, minutes, and hours). Then, starting with the smallest time period (seconds), we check if the value can be converted to the next level of time period. This ensures that the final value for each time period stays below the allowable maximum.

Subtracting

In the example below, we subtract Line 2 from Line 1:

    Line 1: 4hr 00min 00sec
    Line 2: 1hr 15min 30sec
            --------
            2hr 44min 30sec
            --------

For subtraction involving time, a good practice is to start from the smallest time period (the rightmost value in the above example which is seconds). Since we are unable to deduct 30 from 0, we will have to go the next higher level of period (minutes) to borrow a unit. In this case, since the minutes are zero we go to the next period which is hour (remember 60 minutes make 1 hour).

Borrowing from the hour period and breaking down the hour into minutes:

    3hr 60min 00sec
    1hr 15min 30sec

Borrowing a minute and break it down into seconds:

    3hr 59min 60sec
    1hr 15min 30sec

The operation can now be performed:

   Seconds: 60 - 30 = 30
   Minutes: 59 - 15 = 44
   Hours:   3 - 1 = 2

Hence subtracting 1 hour 15 minutes and 30 seconds from 4 hours would result in 2 hours 44 minutes and 30 seconds.

More information:

YouTube video - intended for kids which cover the basics in a fun way.