3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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.6.28, 7.0.0 - 7.1.0
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, hhvm-3.10.0 - 3.12.0
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.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.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.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