YouTip LogoYouTip

Python3 Get Yesterday

# Filename : test.py # author by : www..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())

Executing the above code outputs the following result:

2015-06-10

The output of the above example means that yesterday's date is June 10, 2015.

Document Object Reference Python3 Examples

← Python3 HcfPython3 Conversion Binary Octa β†’