Skip to content » Python Unit Home » Python Date and Time Tutorials

Python Date and Time Tutorials

Time module

import time



duration between two times

start = time.time()

input(“press enter”)

end = time.time()

duration = end – start

Datetime module

Get the current date

Get the current time

Get the current date and time

Find out specific bits of the date

Convert the date to a pretty string

Convert a string formatted date in to a datetime object

Cheat Sheet

Here is a handy reference sheet to download and print.

Countdown tracker


  • Create an app that asks the user to enter a date and an event name.
  • The app should then display the number of days left until that date


  • The app should persistently store the date and event name, displaying it each time the user loads the app in future


  • Expand your app to be a complete event tracker, allowing multiple events
  • The ability to add / remove events

Calendar viewer app


  • Create an app that asks the user to input a year and month.
  • It should then print out that month’s calendar to the user.


  • The app should check that the user has entered a valid year and month, and force the user to reenter the value until a valid amount has been entered.