have a variable I've set up
now = datetime.datetime.now()
I want to be able to set up a variable, yesterday
, that just takes now
and subtracts one day from it.
I'm sure that this is super-easy, but how do I do this?
have a variable I've set up
now = datetime.datetime.now()
I want to be able to set up a variable, yesterday
, that just takes now
and subtracts one day from it.
I'm sure that this is super-easy, but how do I do this?
You can use datetime.timedelta
:
now = datetime.datetime.now()
yesterday = now - datetime.timedelta(days=1)