Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create negative datetime in python 2.7

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.

like image 898
GALIAF95 Avatar asked Mar 11 '26 12:03

GALIAF95


1 Answers

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.

like image 86
aa333 Avatar answered Mar 13 '26 00:03

aa333



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!