Python Get Yesterday's Date
The following code imports the datetime module to get yesterday's date:
# Filename : test.py
# author by : www.example.com
# Import datetime module
import datetime
def getYesterday():
today=datetime.date.today()
oneday=datetime.timedelta(days=1)
yesterday=today-oneday
return yesterday
# Output
print(getYesterday())
The output of the above code is:
2015-06-10
The output of the above example means yesterday's date was June 10, 2015.
Other Extensions
Python3 Examples