Python strftime() to PHP date() Converter
Paste a Python strftime() format to get the equivalent PHP date() format string.
Close equivalent Covers the common case, but has documented behavioral differences.
- Python strftime()
%Y-%m-%d %H:%M:%S- PHP date()
Y-m-d H:i:s
Main limitation: PHP has a direct token for nearly every strftime directive this engine models, so conversions in this direction are exact far more often than the PHP-to-Python direction.
How it differs
- PHP has a direct token for nearly every strftime directive this engine models, so conversions in this direction are exact far more often than the PHP-to-Python direction.
- Python's
%z(UTC offset, no colon, e.g. +0000) maps to PHP'sO; if you need a colon (+00:00), use PHP'sPdirectly — strftime has no directive for the colon form. - Python's
%f(microseconds) maps to PHP'su; there is no strftime directive for milliseconds only, matching PHP's own split betweenu(microseconds) andv(milliseconds).
Examples
Standard timestamp
| Python strftime() | %Y-%m-%d %H:%M:%S |
|---|---|
| PHP date() | Y-m-d H:i:s |
A direct, exact mapping — every strftime directive here has a PHP counterpart.
Long-form date
| Python strftime() | %A, %B %d, %Y |
|---|---|
| PHP date() | l, F d, Y |
Full weekday and month names convert exactly.
ISO-8601 with UTC offset
| Python strftime() | %Y-%m-%dT%H:%M:%S%z |
|---|---|
| PHP date() | Y-m-d\TH:i:sO |
The literal `T` is escaped as `\T` in PHP because `T` is itself a PHP format character; `%z` maps to PHP's `O`.
Edge cases
Edge case
Non-ISO week directives (%U, %W) have no PHP equivalent because PHP's W is always ISO-8601 (Monday-first, week containing the year's first Thursday) — do not substitute W for %U/%W, the week numbering can disagree near year boundaries.
Edge case
A literal T in the source format (common in ISO-8601-style strings) is escaped as \T in the PHP output, since T is itself a PHP format character (timezone abbreviation).
References
- Python docs — strftime() and strptime() format codes (v3.x) — checked 2026-07-29
- PHP Manual — date() — checked 2026-07-29
Last verified 2026-07-29.