from datetime import datetime, timedelta
current_time = datetime.now().time()
new_time = current_time - timedelta(seconds=10)
>> TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.timedelta'
How can I substract time from a datetime.time object? This code seems working only with datetime.datetime objects.
You can just subtract 10 seconds from your current datetime
object before returning the time.
current_time = (datetime.now() - timedelta(seconds=10)).time()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With