Skip to content
Advertisement

convert timestamp to date in custom commands

i am creating custom commands in django. i have a problem with conversion timestamp to date by methods like fromtimestamp. i have such error: line 13, in handle timest_conv = datetime.fromtimestamp(timest) OSError: [Errno 22] Invalid argument

this is my class with handle

JavaScript

Advertisement

Answer

The timestamp is expressed in milliseconds since January 1st, 1970. You thus should divide these by 1’000 to retrieve the timestamp:

JavaScript

for the given sample timestamp, we get:

JavaScript
Advertisement