Link to home
Start Free TrialLog in
Avatar of JohnSantaFe
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.

Avatar of JohnSantaFe
JohnSantaFe

ASKER

I should have said I want to print the total number of seconds and the milliseconds.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of gelonida
gelonida
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.