JohnSantaFe
asked on
Python printing a timedelta as seconds
I have two datetime.datetime objects. When I take the difference between them I get a timedelta object.
When I print the timedelta object, it prints as hh:mm:ss:ms
I would like to convert the timedelta to simply the total number of seconds and print that, however timedelta does not have the strftime capability.
How do I convert the timedelta to simply the total number of seconds?
Thanks.
When I print the timedelta object, it prints as hh:mm:ss:ms
I would like to convert the timedelta to simply the total number of seconds and print that, however timedelta does not have the strftime capability.
How do I convert the timedelta to simply the total number of seconds?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah, it wasn't clear that there are really only days, seconds, and microseconds in a timedelta. There's no need to worry about the hours and minutes.
Thanks.
Thanks.
ASKER
Thanks.