How To Convert Date Before 1970 In Python
I wrote a method to handle mongodb result, where date is coming as datetime.datetime() i used dumps method, which converts the date is not milliseconds, here if the date is before
Solution 1:
I got the solution for date convertion before 1970 as below:
need to replace the code in if((string.find(key,"$date"))>=0):
block as
ndate = datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=(returnValue)/1000)
returnValue = str(ndate).replace(' ','T')
I got the solution from the another question in stackoverflow Timestamp out of range for platform localtime()/gmtime() function
Post a Comment for "How To Convert Date Before 1970 In Python"