HomeCommon › 12-hour time

12-hour time in Python strftime()

A human-friendly clock time with AM/PM.

Format string
%I:%M %p
Example output
01:45 PM

Edit this format in the live tester →

In Python

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

Directives used

%IHour (12-hour clock), zero-padded (01–12).01
%MMinute, zero-padded (00–59).45
%pLocale’s equivalent of AM or PM.PM

Related formats