How to convert a difference in timestamp to miliseconds?

Question:

I have two dates in timestamp and their difference is

dt
0.006951093673706055

dt is: (1669983551.287477-1669983551.280526)

I want to generate several dates (in datetime) with that difference

Now normally I would do

date_list = [datetime.now() + datetime.timedelta(milliseconds=x) for x in range(n)]

but here timedelta uses the number of milliseconds.

So my question is how can I get the timestamp dt 0.006951093673706055 to miliseconds?

Asked By: KansaiRobot

||

Answers:

A time in milliseconds is the time in seconds multiplied by 1000

dt = (1669983551.287477-1669983551.280526) # 0.006951 sec
dt_millisec = dt * 1000                    # 6.951 millisec
Answered By: ACarter
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.