Date and Time in Python — a practical guide to Python datetime with clear examples you can reuse in real projects.
Python Tutorial Series (42/95). Prefer one article? Read the complete Python tutorial.
Short description
Use `datetime` for timestamps, formatting (`strftime`), and parsing (`strptime`).
datetime basics
from datetime import datetime, timedelta
now = datetime.now()
print(now.strftime('%Y-%m-%d %H:%M'))
print(now + timedelta(days=7))