4

I can get current datetime from arrow like this:

arrow.utcnow().date()

or

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

How can I get the previous day datetime? This does not work:

arrow.utcnow().date() - 1

or

 arrow.get('2017-02-01').date() - 1
user308827
  • 21,227
  • 87
  • 254
  • 417

1 Answers1

6

thanks kayluhb. update is to use shift:

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

you can use replace:

 arrow.utcnow().replace(days=-1)
jero
  • 543
  • 3
  • 13
  • 30
  • 2
    Using plural values with replace is being deprecated in favor of 'shift' https://arrow.readthedocs.io/en/latest/#replace-shift. This should become arrow.utcnow().shift(days=-1) – kayluhb Feb 06 '19 at 15:13