Working with Dates and Times

Lesson 17 of 20

Build fixed dates, shift them with timedelta and format them for humans — calendar math without the clock.

The big picture

Calendar math, minus the headaches

The datetime module turns dates into objects you can read, shift, compare and format — no manual month-counting.

Fixed Dates First

date(2025, 1, 15) builds a date you choose — no dependence on today while you learn.

Dates Are Objects

One date object carries year, month and day — read each part with dot access.

Math on the Calendar

Add or subtract timedelta durations; Python handles month and year rollovers.

Text on Demand

strftime turns any date into exactly the text format you need.