Using time.time():

import time

def current_milli_time():
    return round(time.time() * 1000)

Then:

>>> current_milli_time()
1378761833768
Answer from Naftuli Kay on Stack Overflow
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ library โ€บ datetime.html
datetime โ€” Basic date and time types
'milliseconds': Include full time, but truncate fractional second part to milliseconds. HH:MM:SS.sss format. 'microseconds': Include full time in HH:MM:SS.ffffff format. ... Excluded time components are truncated, not rounded.
Discussions

python - Format a datetime into a string with milliseconds - Stack Overflow
In Python 3.11 (maybe older version support it too) it can be done with isoformat(timespec='milliseconds') ... The optional argument timespec specifies the number of additional terms of the time to include. Valid options are 'auto', 'hours', 'minutes', 'seconds', 'milliseconds' and 'microseconds'. >>> datetime.now... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How can I convert a datetime object to milliseconds since epoch (unix time) in Python? - Stack Overflow
I have a Python datetime object that I want to convert to unix time, or seconds/milliseconds since the 1970 epoch. How do I do this? More on stackoverflow.com
๐ŸŒ stackoverflow.com
Add millisecond formatting support to datetime.strftime - Ideas - Discussions on Python.org
Hi, Iโ€™d like to propose adding native support for millisecond precision formatting in Pythonโ€™s datetime.strftime() API. Currently, Python provides: %f in strftime() for microseconds (6 digits) datetime.isoformat(timespec="milliseconds") for ISO output But there is no way to format milliseconds ... More on discuss.python.org
๐ŸŒ discuss.python.org
6
November 28, 2025
Convert python datetime to timestamp in milliseconds - Stack Overflow
Unfortunately I got the error "AttributeError: 'datetime.datetime' object has no attribute 'timestamp'". Possibly because I am using Python 2.7? 2017-01-13T14:05:27.797Z+00:00 ... Yes. Use MYGz's answer for Python 2.7 2017-01-13T14:08:18.003Z+00:00 ... For those who search for an answer without parsing and losing milliseconds... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-get-min-seconds-and-milliseconds-from-datetime-now-in-python
How to get min, seconds and milliseconds from datetime.now() in Python?
August 28, 2025 - Use datetime.now() attributes to directly access time components. Convert microseconds to milliseconds by dividing by 1000.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ get-current-time-in-milliseconds-using-python
Get current time in milliseconds using Python - GeeksforGeeks
July 12, 2025 - To get the time in milliseconds we used the DateTime module, Firstly we printed the date time with seconds. In another line, we printed the milliseconds. ... The time.time() method of the Time module is used to get the time in seconds since ...
๐ŸŒ
W3docs
w3docs.com โ€บ python
How do I get the current time in milliseconds in Python?
By multiplying the result by 1000, we convert the time to milliseconds. The int(round(...)) function is used to round the time to the nearest integer and convert it to an integer.
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ python datetime milliseconds
How to Convert DateTime to String With Milliseconds in Python | Delft Stack
February 2, 2024 - Python provides a straightforward way to achieve this using the strftime method. from datetime import datetime # Get current date and time current_datetime = datetime.now() # Convert to string with milliseconds formatted_datetime = ...
Find elsewhere
๐ŸŒ
Python.org
discuss.python.org โ€บ ideas
Add millisecond formatting support to datetime.strftime - Ideas - Discussions on Python.org
November 28, 2025 - Hi, Iโ€™d like to propose adding native support for millisecond precision formatting in Pythonโ€™s datetime.strftime() API. Currently, Python provides: %f in strftime() for microseconds (6 digits) datetime.isoformat(โ€ฆ
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ date-time-exercise โ€บ python-date-time-exercise-12.php
Python: Get current time in milliseconds - w3resource
July 22, 2025 - Finally it prints the value stored in 'milli_sec', which represents the current time in milliseconds since the epoch. ... Write a Python program to fetch the current time and then display it in milliseconds since the epoch.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-use-strptime-with-milliseconds-in-python
How to use strptime with milliseconds in Python - GeeksforGeeks
July 23, 2025 - Here's how to do it: ... from datetime ... = datetime.strptime(s, format) print(dt_obj) ... Use %f when you want to include milliseconds or microseconds in your datetime string....
๐ŸŒ
Esri Community
community.esri.com โ€บ t5 โ€บ python-questions โ€บ milliseconds-with-strftime โ€บ td-p โ€บ 73258
Solved: Milliseconds with strftime - Esri Community
December 10, 2021 - (I can appended i at the end of new Time as a phony millisecond...) That should just about do it.... Solved! Go to Solution. ... from datetime import datetime curr_time = datetime.now() formatted_time = curr_time.strftime('%H:%M:%S.%f') print(formatted_time) 18:41:59.891075โ€โ€โ€โ€โ€โ€โ€โ€โ€โ€โ€โ€โ€โ€
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ python-add-milliseconds-to-datetime
How to add Milliseconds to Datetime in Python | bobbyhadz
April 8, 2024 - Use the `timedelta()` class from the `datetime` module to add milliseconds to datetime.
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ 5 best ways to get milliseconds in python
5 Best Ways to Get Milliseconds in Python - Be on the Right Side of Change
February 27, 2024 - This provides the time since the epoch as a floating point number, which can then be converted to milliseconds. ... from datetime import datetime timestamp_millis = int(datetime.now().timestamp() * 1000) print(timestamp_millis)
๐ŸŒ
CodeRivers
coderivers.org โ€บ blog โ€บ get-current-time-python-milliseconds
Getting the Current Time in Python with Milliseconds - CodeRivers
April 9, 2025 - Use datetime.now() to get the current date and time as a datetime object. Access the microsecond attribute of the datetime object and divide it by 1000 to get the milliseconds.