Python strftime directive %-I
12-hour hour with no leading zero. Platform-specific (Linux/macOS).
Example (from datetime(2026, 6, 18, 13, 45, 30))
1
This directive uses the
- modifier, which is platform-specific (Linux/macOS, glibc). It is not supported on Windows.In Python
from datetime import datetime
dt = datetime(2026, 6, 18, 13, 45, 30)
dt.strftime("%-I")
# => "1"
Parsing with strptime
Not used for parsing. See strptime.dev for the parsing side.
Other Time directives
%HHour (24-hour clock), zero-padded (00–23).%-H24-hour hour with no leading zero. Platform-specific (Linux/%IHour (12-hour clock), zero-padded (01–12).%pLocale’s equivalent of AM or PM.%MMinute, zero-padded (00–59).%-MMinute with no leading zero. Platform-specific (Linux/macOS)%SSecond, zero-padded (00–59; up to 61 historically for leap s%-SSecond with no leading zero. Platform-specific (Linux/macOS)%fMicrosecond as a decimal number, zero-padded to 6 digits (00