Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datetime: print as seconds

I have a datetime object. I want to print it as just number of seconds (i.e., 1 min 30.5 sec should print as 90.5 s). Can't seem to find a way to do it with strftime.

like image 363
max Avatar asked Sep 10 '26 16:09

max


1 Answers

I think that for your situation you'd be better off using a datetime.timedelta object. It has a function that will do exactly what you want, datetime.timedelta.total_seconds().

like image 97
Vorticity Avatar answered Sep 13 '26 07:09

Vorticity



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!