I am trying to create epoch values for a date field using Python. It works great for all the dates after '1970-01-01'. Any date before 1970 doesn't work.
Here is the code I am using:
int(time.mktime(time.strptime('1969-01-01', '%Y-%m-%d'))) - time.timezone
OverflowError: mktime argument out of range
Is there any alternative way to create negative epoch value?
From the documentation of the
The functions in this module may not handle dates and times before the epoch or far in the future.
So that's out. I would suggest using the
datetime module instead, which can handle dates in years between 1 and 9999. I'm afraid without knowing your use case we can't be of more help.