Python – Get epoch time stamp in milliseconds

To get epoch time stamp in Python we need to time.time() function.

time.time() will returns a float value with double precision counting seconds since epoch and to convert it to milliseconds multiply it with 1000.

With below example code I will show how to get epoch time stamp in milliseconds:

>>> import time
>>> time.time()
1417778138.893148
>>> int(time.time() * 1000)
1417778323455

In above example int(time.time() * 1000) will return epoch time in milliseconds.

Leave a comment