date, time, datetime
Create and read date objects.
Meet the datetime Module
Python's datetime module lives in the standard library and gives you tools to work with calendar dates and clock times.
datestores a year, month, and day.timestores hours, minutes, seconds, and microseconds.datetimecombines both into one object.
Import it with from datetime import date, time, datetime.
from datetime import date, time, datetime
print(date)
print(time)
print(datetime)Creating a date
Build a date by passing year, month, day as integers. Months and days are 1-based and validated automatically.
from datetime import date
birthday = date(1995, 7, 14)
print(birthday)All lessons in this course
- date, time, datetime
- Timedelta and Arithmetic
- Formatting and Parsing
- Time Zones with zoneinfo