Answers for "time sum x hour in python"

1

add hour minutes second python

from datetime import timedelta
t1 = datetime.time(hours, minutes, second) + timedelta(seconds=s, minutes=m, hours=h)
Posted by: Guest on September-01-2020
1

how to add two different times in python

import datetime as dt
t1 = dt.datetime.strptime('12:00:00', '%H:%M:%S')
t2 = dt.datetime.strptime('02:00:00', '%H:%M:%S')
time_zero = dt.datetime.strptime('00:00:00', '%H:%M:%S')
print((t1 - time_zero + t2).time())
Posted by: Guest on April-29-2020

Browse Popular Code Answers by Language