How to Get the Current Time in Milliseconds in Python

The current time on computers is based on the Unix epoch, which is the number of seconds that have elapsed since January 1, 1970 at 00:00:00 GMT (1970-01-01 00:00:00 GMT).

 

In Python, we can get the current time in milliseconds by importing the time package, calling the time.time() function, multiplying the result by 1000 and rounding the result to an integer.

 

Let's try this out with an example.

 

import time

time_milliseconds = round(time.time() * 1000)

print(time_milliseconds)
1619025002280