3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php const TIME_ZONE_FORMAT_NAME = 'utc'; const KEY_VALUE = 'value'; const KEY_NAME = 'name'; const KEY_OFFSET = 'offset'; const KEY_FORMAT = 'format'; const KEY_DISPLAY = 'display'; public function convertTimezoneToArray($timezone, $value) { $dateTime = new \DateTime(); $dateTime->setTimeZone(new \DateTimeZone($timezone)); return [ self::KEY_VALUE => $value, self::KEY_NAME => $timezone, self::KEY_OFFSET => $dateTime->format('P'), self::KEY_FORMAT => self::TIME_ZONE_FORMAT_NAME ]; } public function convertTimezoneList(array $timezonesForCountry) { $timezoneArray = []; foreach ($timezonesForCountry as $timeZone) { if (TimeZone::isTimeZone($timeZone)) { $value = TimeZone::findByFullName($timeZone); $timezoneArray[] = convertTimezoneToArray($timeZone, $value); } } return $timezoneArray; } $inputArray = ["Asia/Yekaterinburg", "Europe/Kaliningrad", "Europe/Moscow", "Europe/Samara"]; convertTimezoneList($inputArray)
Output for 7.0.0 - 7.0.2
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting end of file in /in/9UXqs on line 10
Process exited with code 255.
Output for 5.4.11 - 5.6.17
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/9UXqs on line 10
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_PUBLIC in /in/9UXqs on line 10
Process exited with code 255.