Skip to content
Advertisement

how to divide a datetime object by an int

I can’t seem to divide a datetime.time object by an int.

Looking at the documentation I can’t figure out why it isn’t working.

I get the error: unsupported operand type(s) for /: 'datetime.time' and 'int'.

JavaScript

I did see a method that splits the time down into second then performs the division on the number of seconds, but wondering if there is a better way?

Advertisement

Answer

I think you are confusing a (non-existing) datetime.datetime method with a datetime.timedelta method (see timedelta). Timedeltas can be divided. E.g.:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement