1--TEST-- 2Test date_format() function : timezone offset 3--FILE-- 4<?php 5 6$tz = array("UTC", "Europe/London", "Europe/Berlin", "America/Chicago"); 7 8foreach ($tz as $zone) { 9 echo $zone, "\n"; 10 date_default_timezone_set($zone); 11 12 $date = date_create("2020-03-10 22:30:41"); 13 14 var_dump( date_format($date, "O") ); 15 var_dump( date_format($date, "P") ); 16 var_dump( date_format($date, "p") ); 17} 18 19echo "Z\n"; 20$date = date_create("2020-03-10 22:30:41Z"); 21 22var_dump( date_format($date, "p") ); 23 24?> 25--EXPECT-- 26UTC 27string(5) "+0000" 28string(6) "+00:00" 29string(1) "Z" 30Europe/London 31string(5) "+0000" 32string(6) "+00:00" 33string(6) "+00:00" 34Europe/Berlin 35string(5) "+0100" 36string(6) "+01:00" 37string(6) "+01:00" 38America/Chicago 39string(5) "-0500" 40string(6) "-05:00" 41string(6) "-05:00" 42Z 43string(1) "Z" 44