3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startdate = '2014-05-05 10:00:00'; echo "Start: " . $startdate ."<br/>"; $tzone = new DateTimeZone('Europe/London'); echo "Tzone: " . print_r($tzone, true) ."<br/>"; $dateobj = new DateTime($startdate, $tzone); echo "Date Obj: " . print_r($dateobj, true) ."<br/>"; $formatted = $dateobj->format("c"); echo "Formatted: " . print_r($formatted, true) ."<br/>"; $utzone = new DateTimeZone('UTC'); echo "UTzone: " . print_r($utzone, true) ."<br/>"; $utc = $dateobj->setTimeZone($utzone); echo "UTC: " . print_r($utc, true) ."<br/>"; $formatted2 = $utc->format("c"); echo "Formatted UTC: " . print_r($formatted2, true) ."<br/>";
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Start: 2014-05-05 10:00:00<br/>Tzone: DateTimeZone Object ( [timezone_type] => 3 [timezone] => Europe/London ) <br/>Date Obj: DateTime Object ( [date] => 2014-05-05 10:00:00.000000 [timezone_type] => 3 [timezone] => Europe/London ) <br/>Formatted: 2014-05-05T10:00:00+01:00<br/>UTzone: DateTimeZone Object ( [timezone_type] => 3 [timezone] => UTC ) <br/>UTC: DateTime Object ( [date] => 2014-05-05 09:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) <br/>Formatted UTC: 2014-05-05T09:00:00+00:00<br/>
Output for 5.4.30 - 5.4.45
Start: 2014-05-05 10:00:00<br/>Tzone: DateTimeZone Object ( ) <br/>Date Obj: DateTime Object ( [date] => 2014-05-05 10:00:00.000000 [timezone_type] => 3 [timezone] => Europe/London ) <br/>Formatted: 2014-05-05T10:00:00+01:00<br/>UTzone: DateTimeZone Object ( ) <br/>UTC: DateTime Object ( [date] => 2014-05-05 09:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) <br/>Formatted UTC: 2014-05-05T09:00:00+00:00<br/>
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.29
Start: 2014-05-05 10:00:00<br/>Tzone: DateTimeZone Object ( ) <br/>Date Obj: DateTime Object ( [date] => 2014-05-05 10:00:00 [timezone_type] => 3 [timezone] => Europe/London ) <br/>Formatted: 2014-05-05T10:00:00+01:00<br/>UTzone: DateTimeZone Object ( ) <br/>UTC: DateTime Object ( [date] => 2014-05-05 09:00:00 [timezone_type] => 3 [timezone] => UTC ) <br/>Formatted UTC: 2014-05-05T09:00:00+00:00<br/>
Output for 5.2.0 - 5.2.17
Start: 2014-05-05 10:00:00<br/>Tzone: DateTimeZone Object ( ) <br/>Date Obj: DateTime Object ( ) <br/>Formatted: 2014-05-05T10:00:00+01:00<br/>UTzone: DateTimeZone Object ( ) <br/>UTC: <br/> Fatal error: Call to a member function format() on a non-object in /in/jrZne on line 20
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Start: 2014-05-05 10:00:00<br/> Fatal error: Class 'DateTimeZone' not found in /in/jrZne on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Start: 2014-05-05 10:00:00<br/> Fatal error: Cannot instantiate non-existent class: datetimezone in /in/jrZne on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Start: 2014-05-05 10:00:00<br/> Fatal error: Cannot instantiate non-existent class: datetimezone in /in/jrZne on line 5

preferences:
285.46 ms | 401 KiB | 358 Q