Skip to content Skip to sidebar Skip to footer

Python Cannot Concatenate 'str' And 'datetime.timedelta' Objects

I have this code, but I got an error and could not find a soulution to the problem. I was trying to get a time and then plus i hour becuase i live in europe. Here is my code: plus_

Solution 1:

Convert your string to datetime object.

Ex:

import datetime
plus_one_hour = datetime.datetime.strptime("21:00:00", "%H:%M:%S") + datetime.timedelta(hours=2)
print(plus_one_hour.strftime("%H:%M:%S"))

Output:

23:00:00

Post a Comment for "Python Cannot Concatenate 'str' And 'datetime.timedelta' Objects"