You can get the current time in milliseconds in Python using the time module. You can get the time in seconds using the time.time function (as a floating point value). To convert it to milliseconds, you need to multiply it by 1000 and round up.
import time milliseconds = int (round (time.time () * 1000)) print (milliseconds)
This will output &
If you want to convert a datetime object to a timestamp in milliseconds, you can use the timestamp function and then apply the same math as above, to get the time in milliseconds.
import time from datetime import datetime dt = datetime (2018, 1, 1) milliseconds = int (round (dt.timestamp () * 1000)) print (milliseconds)
This will give the output &