How to get yesterday date in Python?
In this example, I will show you how to get yesterday date in python. we will implement a python get yesterday date.
let’s see below example code and try it.
from datetime import datetime, timedelta
today = datetime.now()
yesterday = today - timedelta(1)
tomorrow = today + timedelta(1)
print("Yesterday Date :", yesterday.strftime('%d-%m-%Y))
print("Today Date :", today.strftime('%d-%m-%Y))
print("Tomorrow Date :", tomorrow.strftime('%d-%m-%Y))
Yesterday Date : 28-06-2022
Today Date : 29-06-2022
Tomorrow Date : 30-06-2022
I hope you like this article.
Also Read :
- How to Check if Today is Friday or not in Python?
- Python GET Request with Parameters
- Python POST Request with Parameters Example
- Top 10 VS Code extensions
- Angular Material Grid Layout Example
- Angular Material Card Example
- CSS Profile Card Design
- CSS Responsive List View Examples