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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s