如何使用箭头增加日期?

时间:2016-06-09 16:05:29

标签: python datetime arrow-python

我正在使用arrow模块来处理Python中的datetime个对象。如果我得到这样的当前时间:

now = arrow.now()

...如何将它增加一天?

3 个答案:

答案 0 :(得分:2)

增加一天

now.replace(days=1)

减少一天

now.replace(days=-1)

I highly recommend the docs.

答案 1 :(得分:0)

请参阅documentation

<field name = "id" type = "string" indexed = "true" stored = "true" required="true"/>
<field name = "name" type = "string" indexed = "true" stored = "true" required="true" multiValued="false"/>
<field name = "gender" type = "string" indexed = "true" stored = "true" required="true" multiValued="false"/>
<field name = "number" type = "string" indexed = "true" stored = "true" required="true" multiValued="true"/>

答案 2 :(得分:0)

docs指出shift将用于添加偏移量:

now.shift(days=1)

带有replacedayshours等参数的minutes方法似乎和shift一样工作,尽管replace也有dayhourminute等参数,用提供的值替换给定字段中的值。

无论如何,我认为now.shift(hours=-1)now.replace更清晰。