Timestamp out of range for platform localtime()/gmtime() function

Viewed 17824

I try:

ts = -216345600000
datetime.datetime.fromtimestamp(ts/1000)

ValueError: timestamp out of range for platform localtime()/gmtime() function

I check on epochconverter value : -216345600 its return GMT: Sat, 23 Feb 1963 00:00:00 GMT

How to get the correct result?

2 Answers

Maybe slightly less related to the problem from the question but may be applicable to those who want to represent full date-time range without any very specific workarounds to limitations of the default datetime implementation.

I have checked a few libraries and I suggest using:

dateparser - for parsing date/time stated naturally for a human being and in multitude of languages.

arrow - drop-in replacement for datetime without its limitations (e.g. possibility to represent dates before and close to the epoch of 1. year AD).

Related