Just convert it to timestamp

datetime.datetime.fromtimestamp(ms/1000.0)
Answer from vartec on Stack Overflow
Discussions

Convert python datetime to timestamp in milliseconds - Stack Overflow
How do I convert a human-readable time such as 20.12.2016 09:38:42,76 to a Unix timestamp in milliseconds? More on stackoverflow.com
🌐 stackoverflow.com
python - Format a datetime into a string with milliseconds - Stack Overflow
@Cabbi raised the issue that on some systems (Windows with Python 2.7), the microseconds format %f may incorrectly give "0", so it's not portable to simply trim the last three characters. Such systems do not follow the behavior specified by the documentation: The following code carefully formats a timestamp with milliseconds: >>> from datetime ... More on stackoverflow.com
🌐 stackoverflow.com
Converting unix timestamps in python
Your timestamp is in milliseconds. It should be seconds. More on reddit.com
🌐 r/learnpython
7
3
October 23, 2024
How to convert a number of milliseconds since Year 0 into a pandas Timestamp (or some other object with year, month, day, hour, minute, second)?
my_dataframe.timestamp_column = pandas.to_datetime(my_dataframe.timestamp_column) That should automatically detect the input format (unix timestamp; the number of milli/seconds since 1st Jan 1970) and convert that column to a pandas.DateTime type. If the dates are still off then you can pass the exact unit to the method ​ my_dataframe.timestamp_column = pandas.to_datetime(my_dataframe.timestamp_column, unit="ms") If you are working with a non-unix epoch (practically this just means the start of a range of time) you can pass the start date with the origin argument (starting at the new millenium for example): ​my_dataframe.timestamp_column = pandas.to_datetime(my_dataframe.timestamp_column, unit="ms", origin=pd.Timestamp("2000-01-01")) More on reddit.com
🌐 r/learnpython
10
11
October 25, 2022
🌐
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(…
🌐
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....
🌐
GeeksforGeeks
geeksforgeeks.org › python › get-current-time-in-milliseconds-using-python
Get current time in milliseconds using Python - GeeksforGeeks
July 12, 2025 - # Import class time from time module from time import time milliseconds = int(time() * 1000) print("Time in milliseconds since epoch", milliseconds) ... Note: The epoch is the point where the time starts and is platform-dependent.
Find elsewhere
🌐
GitHub
gist.github.com › evnm › d17336bf42e887c6e756
Script to convert milliseconds since epoch to a human-readable timestamp · GitHub
Script to convert milliseconds since epoch to a human-readable timestamp - gist:d17336bf42e887c6e756
🌐
TutorialsPoint
tutorialspoint.com › how-to-convert-python-datetime-string-into-integer-milliseconds
How to convert Python DateTime string into integer milliseconds?
August 28, 2025 - Current date in string format: 2022-09-05 10:31:52.853660 Number of days since epoch: 19240 days, 10:31:52.853671 Milliseconds since epoch: 1662373912854 · The timestamp() function from the datetime module is used to convert any datetime object to seconds since the epoch (floating-point number).
🌐
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. ValueError will be raised on an invalid timespec argument: >>> import datetime as dt >>> dt.datetime.now().isoformat(timespec='minutes') '2002-12-25T00:00' >>> my_datetime = dt.datetime(2015, 1, 1, 12, 30, 59, 0) >>> my_datetime.isoformat(timespec='microseconds') '2015-01-01T12:30:59.000000'
🌐
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 - In the following example code, we get the current minutes, seconds, and milliseconds using the datetime.now() method. from datetime import datetime now = datetime.now() print("Today's date is:", now) print("Minutes",now.minute) print("Secon...
🌐
InfluxData
influxdata.com › home › how to convert timestamp to datetime in python | influxdata
How to Convert Timestamp to DateTime in Python | InfluxData
June 28, 2023 - First, let’s get an overview of what timestamps and datetimes are in Python. A timestamp is a numeric representation of a specific point in time. It’s usually represented as the number of seconds (or sometimes milliseconds) that have elapsed since a specific reference point called the ...
🌐
Kontext
kontext.tech › home › blogs › code snippets & tips › convert timestamp to milliseconds since epoch in python
Convert Timestamp to Milliseconds since Epoch in Python - Kontext Labs
August 22, 2022 - import datetime now = datetime.datetime.utcnow() now_local = datetime.datetime.now() epoch = datetime.datetime.utcfromtimestamp(0) milliseconds = (now - epoch).total_seconds() * 1000.0 print(milliseconds) # For python version >=3.3 milliseconds ...
🌐
w3resource
w3resource.com › python-exercises › date-time-exercise › python-date-time-exercise-12.php
Python: Get current time in milliseconds - w3resource
July 22, 2025 - The result is rounded to the nearest integer using the "round()" function to ensure a whole number. The rounded value representing the current time in milliseconds is stored in the variable 'milli_sec'. 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.
🌐
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 - The datetime.datetime.now() function provides the current local date and time, from which one can extract the time in milliseconds.
🌐
Codemia
codemia.io › knowledge-hub › path › how_do_i_get_the_current_time_in_milliseconds_in_python
How do I get the current time in milliseconds in Python?
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
Finxter
blog.finxter.com › home › learn python blog › 5 best ways to convert python time to milliseconds
5 Best Ways to Convert Python Time to Milliseconds - Be on the Right Side of Change
February 27, 2024 - This one-liner uses the time_ns() function to get the current time in nanoseconds and directly converts it to milliseconds, demonstrating the power and conciseness of Python’s list comprehensions and underscored integer literals for readability.
🌐
Python
docs.python.org › 3 › library › time.html
time — Time access and conversions
The %f format directive only applies to strptime(), not to strftime(). However, see also datetime.datetime.strptime() and datetime.datetime.strftime() where the %f format directive applies to microseconds.
🌐
Reddit
reddit.com › r/learnpython › converting unix timestamps in python
r/learnpython on Reddit: Converting unix timestamps in python
October 23, 2024 -

Hi I'm trying to figure out how to convert unix timestamps. My code just looks like this right now but I'm getting the following error. Anybody know what I'm doing wrong?

import datetime

timestamp = 1729322547223
dt_object = datetime.datetime.fromtimestamp(timestamp)
print(dt_object)

Traceback (most recent call last):
  File "c:\Users\elieh\OneDrive\Documents\friendsgg\main.py", line 21, in <module>
    dt_object = datetime.datetime.fromtimestamp(timestamp)
OSError: [Errno 22] Invalid argument