How to get current time in milliseconds in Python?

PythonServer Side ProgrammingProgramming

You can get the current time in milliseconds in Python using the time module. You can get the time in seconds using time.time function(as a floating point value). To convert it to milliseconds, you need to multiply it with 1000 and round it off. 

Example

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

Output

This will give the output −

1514825676008
raja
Published on 08-Jan-2018 11:01:06
Advertisements