HomeDocs › %I

Python strftime directive %I

Hour (12-hour clock), zero-padded (01–12).

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

In Python

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

Parsing with strptime

Parses a 12-hour hour; combine with %p. See strptime.dev for the parsing side.

Try %I in the live tester →

Other Time directives