【问题标题】:Getting previous day datetime from arrow从箭头获取前一天的日期时间
【发布时间】:2017-08-23 13:49:14
【问题描述】:

我可以像这样从箭头获取当前日期时间:

arrow.utcnow().date()

arrow.get('2017-02-01').date()

如何获取前一天的日期时间?这不起作用:

arrow.utcnow().date() - 1

 arrow.get('2017-02-01').date() - 1

【问题讨论】:

    标签: python datetime arrow-python


    【解决方案1】:

    感谢 kayluhb。更新是使用shift:

    arrow.utcnow().shift(days=-1)
    

    你可以使用替换:

     arrow.utcnow().replace(days=-1)
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-14
    • 2011-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-11
    • 2023-03-26
    • 2019-04-10
    相关资源
    最近更新 更多