I want to add two time values t1 and t2 in format 'HH:MM:SS'.
t1 ='12:00:00'
t2='02:00:00'
t1+t2
should be 14:00:00
I tried t1+t2
. But as t1
& t2
are im string format the output was concatenation 12:00:00 02:00:00
.
So I tried to convert in datetime.datetime.strptime().time() object like
t1 = datetime.datetime.strptime('12:00:00', '%H:%M:%S').time()
t2 = datetime.datetime.strptime('02:00:00', '%H:%M:%S').time()
but gives error
TypeError: unsupported operand type(s) for +: 'datetime.time' and 'datetime.time'
How can I get this to work?
datetime
objects, not thetime
objects.