Python Projects & Skills / Files and data
Lesson 14 of 28
Dates and times
The datetime module handles dates, times and differences between them.
Key points
- datetime.now()
- timedelta(days=7)
- strftime formats dates
from datetime import datetime, timedelta
next_week = datetime.now() + timedelta(days=7)
print(next_week.strftime("%Y-%m-%d"))Quiz · +10 XP
Which class represents a length of time, like 7 days?
Log in to save progress and earn XP.