Get current time in milliseconds in Python?

Naftuli Kay picture Naftuli Kay · May 14, 2011 · Viewed 832.2k times · Source

How can I get the current time in milliseconds in Python?

Answer

Naftuli Kay picture Naftuli Kay · May 14, 2011

For what I needed, here's what I did, based on @samplebias' comment above:

import time
millis = int(round(time.time() * 1000))
print millis

Quick'n'easy. Thanks all, sorry for the brain fart.

For reuse:

import time

current_milli_time = lambda: int(round(time.time() * 1000))

Then:

>>> current_milli_time()
1378761833768