I have to get a datetime
from a float using Python. I am tryint to use the following code:
import time
print (time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(float(63650571169.50261))))
But when executing this code, I get an error:
OSError: [Errno 22] Invalid argument
The sys.float_info.max
displays 1.7976931348623157e+308
.
How do I convert this float number into a datetime
?
Try this :
It looks like your OS is using the ISO 8601:2004 (clause 4.3.2.1 The Gregorian calendar) with the epoch at Year 0. This can be converted by applying the correct zero offset as:
Code:
Test Code:
Results: