how to add two different times in python

Solutions on MaxInterview for how to add two different times in python by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "how to add two different times in python"
Cletus
10 Jan 2021
1import datetime as dt
2t1 = dt.datetime.strptime('12:00:00', '%H:%M:%S')
3t2 = dt.datetime.strptime('02:00:00', '%H:%M:%S')
4time_zero = dt.datetime.strptime('00:00:00', '%H:%M:%S')
5print((t1 - time_zero + t2).time())