Adding two timedelta instances

Adding multiple timedelta instances returns a timedelta providing the total time duration from them.

Timedelta Updated 6 Aug 2021 1 min read

Overview

  • Through addition, two or more time durations from timedelta instances can be added to obtain the total time duration. For example, time durations taken by two or more tasks are summed together to get the total time taken.

Example

python
# Example Python program that adds multiple

            # time durations specified by the datetime.timedelta

            # instances

            from datetime import timedelta

t1Player1Relay = timedelta(seconds = 12)

            t1Player2Relay = timedelta(seconds = 14)

            t1Player3Relay = timedelta(seconds = 16)

            t1Player4Relay = timedelta(seconds = 16)

t1TotalTime = t1Player1Relay + t1Player2Relay + t1Player3Relay + t1Player4Relay

print("Team1 total relay race time:")

            print(t1TotalTime)

Output

Output
Team1 total relay race time:

0:00:58