Date, Time and Localization Modules
datetime
Provides date, time, datetime, timedelta and timezone objects. Aware datetime objects have meaningful UTC offsets; naive objects do not identify an unambiguous instant. Use timezone.utc for UTC and zoneinfo for regional rules. Timedelta arithmetic expresses durations or calendar-relative wall-clock changes depending on the operation.
Formal Syntax & Structure
python syntaxpython
import datetimeReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from datetime import date, timedeltastart = date(2024, 2, 28)print(start + timedelta(days=2))