Dates & Times
link - docs.python.org/3/library/datetime.html
Modules
calendar - General calendar related functions.
time - Time access and conversions.
zoneinfo - Concrete time zones representing the IANA time zone database.
Third Party Packages
dateutil - Third-party library with expanded time zone and parsing support.
datetype - Third-party library that introduces distinct static types to e.g. allow static type checkers to differentiate between naive and aware datetimes.
Date Class
DateTime Class
from datetime import datetime
current_date = datetime.now()
print('Today is: ' + str(current_date))
from datetime import timedelta
today = datetime.now()
one_day = timedelta(days=1)
yesterday = today - one_day
print('Yesterday was: ' + str(yesterday))
print('Day: ' + str(current_day.day))
print('Month: ' + str(current_day.month))
print('Year: ' + str(current_day.year))
birthday = input('When is your birthday (dd/mm/yyyy)? ')
birthday_date = datetime.strptime(birthday, '%d/%m/%Y')
print ('Birthday: ' + str(birthday_date))
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopNext