如何在python 2.7中创建负日期时间 [英] How to create negative datetime in python 2.7

查看:119
本文介绍了如何在python 2.7中创建负日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在mongo db中插入一些BC日期,但是我不能创建带有负值的日期时间,例如datetime.datetime(-2000, 2, 1),但是在mongodb中可以使用IsoDate,所以如何在python中创建否定日期? 我目前正在使用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.

推荐答案

Python 2.7的日期时间库只能处理广告日期.如果您需要进一步研究,则必须查看其他库,例如 Astropy中的Time类. datautil 中的a>或date.

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.

这篇关于如何在python 2.7中创建负日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆