Skip to content
UPEEC

datetime

Dates, times, durations and formatting.

Easy
Comments 0
from datetime import datetime, timedelta, timezone
now = datetime.now(timezone.utc)
deadline = now + timedelta(days=7)
datetime.strptime("23-10-2026", "%d-%m-%Y")
now.isoformat(), now.strftime("%d %b %Y")

Store and compare times in UTC; convert to local time only for display.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.