Editor

Create and Display a Date

Beginner · Write the code · from Python datetime: Dates, Times, Timezones, and Calculations

From the lesson: Python datetime: Dates, Times, Timezones, and Calculations

Think about your phone. It shows the current time, tracks your calendar events, and reminds you about birthdays. Behind the scenes, all of that runs on date and time calculations.

Read the lesson

Create a date object for July 4, 2024. Print it in the format July 04, 2024 using strftime.

from datetime import date
# Create July 4, 2024 and print formatted

More datetime exercises

All Python exercises · 50 practice problems · Standard Library Essentials quiz