HomeDocs › %y

Python strftime directive %y

Year without century, zero-padded (00–99).

Example (from datetime(2026, 6, 18, 13, 45, 30))
26

In Python

from datetime import datetime
dt = datetime(2026, 6, 18, 13, 45, 30)
dt.strftime("%y")
# => "26"

Parsing with strptime

Parses a 2-digit year; 69–99 → 1969–1999, 00–68 → 2000–2068. See strptime.dev for the parsing side.

Try %y in the live tester →

Other Year directives