format(), and date() for timestamps, build a string from single-letter codes: day d/j/D/l/S, month m/n/M/F, year Y/y, clock H/G/h/g/i/s/v/u/A, zone e/T/P, and the calendar codes shown below. Escape a literal letter with \.
<?php
$d = new DateTimeImmutable('2026-03-01 14:05:09.123456', new DateTimeZone('Europe/Berlin'));
foreach (['jS F Y, l g:i A', 'D W N z t L', 'H:i:s.v e T P U', '\W\e\e\k W \o\f o',
DATE_ATOM, DATE_RFC2822] as $f) {
printf("%-18s %s\n", $f, $d->format($f));
}
echo $d->setTimezone(new DateTimeZone('UTC'))->format('D, d M Y H:i:s \G\M\T'), "\n";
foreach (['de_DE', 'ms_MY', 'zh_CN'] as $locale) { // needs ext-intl
echo $locale, ' ', new IntlDateFormatter($locale, IntlDateFormatter::FULL,
IntlDateFormatter::SHORT, 'Asia/Kuala_Lumpur')->format($d), "\n";
}Output
jS F Y, l g:i A 1st March 2026, Sunday 2:05 PM D W N z t L Sun 09 7 59 31 0 H:i:s.v e T P U 14:05:09.123 Europe/Berlin CET +01:00 1772370309 \W\e\e\k W \o\f o Week 09 of 2026 Y-m-d\TH:i:sP 2026-03-01T14:05:09+01:00 D, d M Y H:i:s O Sun, 01 Mar 2026 14:05:09 +0100 Sun, 01 Mar 2026 13:05:09 GMT de_DE Sonntag, 1. März 2026 um 21:05 ms_MY Ahad, 1 Mac 2026 pada 9:05 PTG zh_CN 2026年3月1日星期日 21:05
Use DATE_ATOM (ISO 8601) for APIs and logs. For HTTP headers, convert to UTC and use the literal GMT pattern shown: PHP 8.5 deprecated DATE_RFC7231, which printed "GMT" without converting. date() speaks only English; IntlDateFormatter gives each reader's language and also accepts ICU patterns such as 'EEEE d MMMM y'. strftime() has been deprecated since PHP 8.1.