timedelta
A datetime value representing a length of time, such as timedelta(days=7), which you add to or subtract from dates.
In more detail
Subtracting one date from another gives a timedelta, whose .days attribute and total_seconds() method report its size. It can hold days, seconds and microseconds, including negative lengths.
Example
from datetime import date, timedelta
date.today() + timedelta(days=30)Related terms
- datetime module — The standard library module for dates and times as real values you can compare, add to and format, not as text.
Taught in
- Dates, Times And Random — Hands-on Python: Complete Video Course & Book