How to create negative datetime in python 2.7

戏子无情 提交于 2019-12-11 11:08:50

问题


I need to insert into mongo db some BC dates but I cant create datetime with negative value like datetime.datetime(-2000, 2, 1), but in mongodb it is possible to do with IsoDate, so how can i create negative dates in python? I'm currently using python 2.7, and i do it on purpouse, for the project.


回答1:


Python 2.7's datetime library can only handle AD dates. If you need to go back further than that you will have to look at other libraries such as the Time class in Astropy or date in datautil.



来源:https://stackoverflow.com/questions/32161570/how-to-create-negative-datetime-in-python-2-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!