3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function time_offset($timezone = null) { if ($timezone <> null) { $offset = false; try { $time = @new DateTime(); @$time->setTimezone(new DateTimeZone($timezone)); $offset = @$time->getOffset(); } catch (Exception $e) { } $output = is_numeric($offset) ? $offset : false; } else { $output = strtotime(date("Y-m-d H:i:s")) - strtotime(gmdate("Y-m-d H:i:s")); } return $output; } var_dump(time_offset());
Output for 5.0.0 - 7.1.0
int(3600)
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/AW7pG on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '{' in /in/AW7pG on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/AW7pG on line 6
Process exited with code 255.