I have two strings in Python that are used to store user entered times. They are formatted as hh:mm:ss - eg 09:17:34
What is the easiest way to find the difference, in seconds, between these two times? The times will always be on the same day, so no need to worry about overlapping midnight, etc.
If I use string slicing to take out the relevant digits, then use datetime.datetime()
, I can set up a datetime
object for each, but I need to give it a date as well as the time I have.
I've played around with the time
module, but this doesn't seem to have an easy way of working out differences in the way that using .total_seconds
on a timedelta
object does.
Is there any easier way?