JavaScript date-fns format() to PHP date() Converter

Paste a date-fns format() token string to get the equivalent PHP date() format string.

Token-by-token mapping

Shown one token at a time — some dialects combine two adjacent tokens (like a day number plus an ordinal suffix) into a single result above, which can differ slightly from this per-token view.

Close equivalent Covers the common case, but has documented behavioral differences.

JavaScript (date-fns)
yyyy-MM-dd HH:mm:ss
PHP date()
Y-m-d H:i:s

Main limitation: date-fns's combined ordinal-day token `do` (renders as "5th") decomposes into PHP's `j` (day number) immediately followed by `S` (suffix) — both characters are required to reproduce the same output.

How it differs

  • date-fns's combined ordinal-day token do (renders as "5th") decomposes into PHP's j (day number) immediately followed by S (suffix) — both characters are required to reproduce the same output.
  • date-fns quotes literal text in single quotes ('at'); PHP instead escapes each special character individually with a backslash (\a\t).
  • date-fns has no microseconds token, so there is nothing to map to PHP's u in this direction — PHP's extra precision token simply has no source equivalent to convert from.

Examples

Standard timestamp

JavaScript (date-fns) yyyy-MM-dd HH:mm:ss
PHP date() Y-m-d H:i:s

A direct, exact mapping in both directions.

Ordinal day, decomposed automatically

JavaScript (date-fns) EEEE, do MMMM yyyy
PHP date() l, jS F Y

date-fns's combined `do` becomes PHP's `j` (day number) immediately followed by `S` (suffix) — the conversion is exact.

Edge cases

Edge case

date-fns quarter tokens (Q, QQQ) and non-ISO week tokens (w) have no PHP equivalent and are dropped with a warning rather than approximated.

Edge case

A doubled single quote ('') in date-fns, representing a literal quote character, is unescaped correctly before being re-escaped for PHP.

References

  • date-fns — format() — checked 2026-07-29
  • PHP Manual — date() — checked 2026-07-29

Last verified 2026-07-29.