Log timestamp in Python strftime()
The default timestamp format used by Python’s logging module.
Format string
%Y-%m-%d %H:%M:%S,%f
Example output
2026-06-18 13:45:30,000000
Edit this format in the live tester →
In Python
from datetime import datetime
dt = datetime(2026, 6, 18, 13, 45, 30)
dt.strftime("%Y-%m-%d %H:%M:%S,%f")
# => "2026-06-18 13:45:30,000000"
Directives used
| %Y | Year with century as a decimal number. | 2026 |
| %m | Month as a zero-padded number (01–12). | 06 |
| %d | Day of the month, zero-padded (01–31). | 18 |
| %H | Hour (24-hour clock), zero-padded (00–23). | 13 |
| %M | Minute, zero-padded (00–59). | 45 |
| %S | Second, zero-padded (00–59; up to 61 historically for leap seconds). | 30 |
| %f | Microsecond as a decimal number, zero-padded to 6 digits (000000–999999). | 000000 |