3v4l.org

run code in 200+ PHP versions simultaneously
<?php $dt1 = new DateTime("2016-01-01 20:00:00+00:00"); $dt2 = new DateTime("2016-01-01 20:00:00+00:00"); $tz_ok= new DateTimeZone('Europe/Paris'); $tz_bad = new DateTimeZone('+01:00'); for ($i = 0; $i < 5; $i++) { $dt1->setTimezone($tz_ok); $dt2->setTimezone($tz_bad); print($dt1->format(DATE_RFC822) . " -- " .$dt2->format(DATE_RFC822) . "\n"); } $dt2->setTimezone($tz_ok); print($dt2->format(DATE_RFC822) . "\n");
Output for 7.0.17 - 7.0.33, 7.1.3 - 7.4.1
Fri, 01 Jan 16 21:00:00 +0100 -- Fri, 01 Jan 16 21:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100 -- Fri, 01 Jan 16 21:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100 -- Fri, 01 Jan 16 21:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100 -- Fri, 01 Jan 16 21:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100 -- Fri, 01 Jan 16 21:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100
Output for 5.5.10 - 7.0.16, 7.1.0 - 7.1.2
Fri, 01 Jan 16 21:00:00 +0100 -- Fri, 01 Jan 16 21:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100 -- Fri, 01 Jan 16 22:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100 -- Fri, 01 Jan 16 23:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100 -- Sat, 02 Jan 16 00:00:00 +0100 Fri, 01 Jan 16 21:00:00 +0100 -- Sat, 02 Jan 16 01:00:00 +0100 Sat, 02 Jan 16 02:00:00 +0100
Output for 5.2.0 - 5.5.9
Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (+01:00)' in /in/QMpLM:7 Stack trace: #0 /in/QMpLM(7): DateTimeZone->__construct('+01:00') #1 {main} thrown in /in/QMpLM on line 7
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/QMpLM on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/QMpLM on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/QMpLM on line 3