Python strftime directive %Y
Year with century as a decimal number.
Example (from datetime(2026, 6, 18, 13, 45, 30))
2026
In Python
from datetime import datetime
dt = datetime(2026, 6, 18, 13, 45, 30)
dt.strftime("%Y")
# => "2026"
Parsing with strptime
Parses a 4-digit year (e.g. 2026). See strptime.dev for the parsing side.