HomeDocs › %X

Python strftime directive %X

Locale’s appropriate time representation.

Example (from datetime(2026, 6, 18, 13, 45, 30))
1:45:30 PM
Output depends on the active locale; in Python it follows the process locale (locale.setlocale). This page and the tester show the C/English value.

In Python

from datetime import datetime
dt = datetime(2026, 6, 18, 13, 45, 30)
dt.strftime("%X")
# => "1:45:30 PM"

Parsing with strptime

Parsing depends on the locale; brittle, avoid. See strptime.dev for the parsing side.

Try %X in the live tester →

Other Locale directives