Date and time in Python

We'll cover the following

Python gives the developer several tools for working with dates and time. In this chapter, we will be looking at the datetime and time modules. We will study how they work and some common uses for them. Let’s start with the datetime module!

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.

Get hands-on with 1200+ tech skills courses.