3 examples of 'python datetime yesterday' in Python

Every line of 'python datetime yesterday' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
62def yesterday():
63 """
64 Refs: #13842, #note-30.
65 """
66 return datetime.date.today() - datetime.timedelta(1)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

33def yesterday():
34 return timezone.now().date() - timezone.timedelta(days=1)
68def yesterday():
69 """
70 Get yesterday's datetime as a 5-tuple.
71 """
72 date = datetime.datetime.now()
73 date -= datetime.timedelta(days=1)
74 date_tuple = date.timetuple()[:6]
75 return date_tuple

Related snippets