Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert timedelta to milliseconds python

I have the following time:

time = datetime.timedelta(days=1, hours=4, minutes=5, seconds=33, milliseconds=623)

Is it possible, to convert the time in milliseconds?
Like this:

101133623.0
like image 867
ranqnova Avatar asked Jan 24 '26 08:01

ranqnova


1 Answers

I found a possibility to solve the problem

import datetime

time = datetime.timedelta(days=1, hours=4, minutes=5, seconds=33, milliseconds=623)
result = time.total_seconds()*1000
print(result)

like image 111
ranqnova Avatar answered Jan 26 '26 21:01

ranqnova



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!