How to Get the Current Time in Python

Sebastian Oliver

Getting the current time in Python is a nice starting point for many time-related operations. One very important use case is creating timestamps. In this tutorial, you’ll learn how to get, display, and format the current time with the datetime module.

To effectively use the current time in your Python applications, you’ll add a few tools to your belt. For instance, you’ll learn how to read attributes of the current time, like the year, minutes, or seconds. To make the time more easily readable, you’ll explore options for printing it. You’ll also get to know different formats of time and understand how to deal with time zones.

What’s Included:

Downloadable Resources:

About Sebastian Oliver

Sebastian (PhD) is an Assistant Professor in Digital & Data Driven Marketing at the University of Southampton. He is also an avid Pythonista and Real Python video tutorial contributor.

» More about Sebastian

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

« Browse All Courses