-1

I have a variable named "timestamp" and the value of it is "1617108899460", how would I turn this into this format: month/day/year, hour:minutes:seconds

I tried to do the following but I got an error:

date_time = datetime.fromtimestamp(timestamp).strftime("%A, %B %d, %Y %I:%M:%S")
OSError: [Errno 22] Invalid argument

Is there any way I can do this in a simple way? Like with a module?

container
  • 1
  • 3

1 Answers1

-1

Duplicate of this. Your timestamp value is in milliseconds.

from datetime import datetime
timestamp = 1617108899460
date_time = datetime.fromtimestamp(timestamp / 1e3).strftime("%A, %B %d, %Y %I:%M:%S")

This works as expected.