The datetime Module

We will be learning about the following classes from the datetime module:

  • datetime.date
  • datetime.timedelta
  • datetime.datetime

These will cover the majority of instances where you’ll need to use date and datetime object in Python. There is also a tzinfo class for working with time zones that we won’t be covering. Feel free to take a look at the Python documentation for more information on that class.

datetime.date

Python can represent dates several different ways. We’re going to look at the datetime.date format first as it happens to be one of the simpler date objects.

Get hands-on with 1200+ tech skills courses.