0

I am trying to collect some data from Dynamics App, and I would like to convert the metric timestamp to a human script, but I am getting this error, any suggestions for a solution ?

Script

from datetime import datetime

timestamp = 1630548180000
dt_object = datetime.fromtimestamp(timestamp)

Output

Traceback (most recent call last):
  File "C:\Users\Developer\Desktop\test.py", line 4, in <module>
    dt_object = datetime.fromtimestamp(timestamp)
OSError: [Errno 22] Invalid argument
Luis Henrique
  • 701
  • 15
  • 36

1 Answers1

1

Python datetime expects epoch seconds, but it seems you have timestamp of milliseconds, so you need to divide this value by 1000.

Antonio Prates
  • 322
  • 2
  • 5