3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tzList = array(); $tzList[54] = array('name' => 'Moscow, St. Petersburg, Volgograd', 'tz' => 'Europe/Moscow', 'country' => array('RU')); $timeZoneDataId = array(); $timeZoneDataJs = array(); $timeZonesystemName = array(); $year = date('Y'); foreach ($tzList as $key => $tz) { $temp = array(); try { $dateTimeZone = new DateTimeZone($tz['tz']); $dateTimeWinter = new DateTime($year . "-1-1", $dateTimeZone); $dateTimeSummer = new DateTime($year . "-6-30", $dateTimeZone); $dateNow = new DateTime("now", $dateTimeZone); $temp['n'] = $tz['name']; $temp['n'] = $key; if ($countryName && in_array($countryName, $tz['country'])) { $temp['c'] = 1; } $temp['o'] = $dateTimeZone->getOffset($dateNow) / 3600; $summerOffset = $dateTimeZone->getOffset($dateTimeSummer); $winterOffset = $dateTimeZone->getOffset($dateTimeWinter); $nowOffset = $dateTimeZone->getOffset($dateNow); $timeZoneDataId[$tz['tz']] = $key; $timeZoneDataJs[$summerOffset][$winterOffset][] = $temp; $timeZonesystemName[$key] = $tz['tz']; //add info to tzList $tzList[$key]['offsetNow'] = $nowOffset / 3600; $tzList[$key]['id'] = $key; } catch (Exception $e) { //echo '*' . $tz['tz'] . '*'; } } var_dump($tzList);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Undefined variable $countryName in /in/8aNTC on line 19 array(1) { [54]=> array(5) { ["name"]=> string(33) "Moscow, St. Petersburg, Volgograd" ["tz"]=> string(13) "Europe/Moscow" ["country"]=> array(1) { [0]=> string(2) "RU" } ["offsetNow"]=> int(3) ["id"]=> int(54) } }
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.6, 5.4.34 - 5.4.45, 5.5.18 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: countryName in /in/8aNTC on line 19 array(1) { [54]=> array(5) { ["name"]=> string(33) "Moscow, St. Petersburg, Volgograd" ["tz"]=> string(13) "Europe/Moscow" ["country"]=> array(1) { [0]=> string(2) "RU" } ["offsetNow"]=> int(3) ["id"]=> int(54) } }
Output for 7.3.32 - 7.3.33
array(1) { [54]=> array(5) { ["name"]=> string(33) "Moscow, St. Petersburg, Volgograd" ["tz"]=> string(13) "Europe/Moscow" ["country"]=> array(1) { [0]=> string(2) "RU" } ["offsetNow"]=> int(3) ["id"]=> int(54) } }
Output for 5.3.7 - 5.3.29, 5.4.0 - 5.4.32, 5.5.0 - 5.5.16
Notice: Undefined variable: countryName in /in/8aNTC on line 19 array(1) { [54]=> array(5) { ["name"]=> string(33) "Moscow, St. Petersburg, Volgograd" ["tz"]=> string(13) "Europe/Moscow" ["country"]=> array(1) { [0]=> string(2) "RU" } ["offsetNow"]=> int(4) ["id"]=> int(54) } }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Class 'DateTimeZone' not found in /in/8aNTC on line 13
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/8aNTC on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected '{' in /in/8aNTC on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/8aNTC on line 12
Process exited with code 255.

preferences:
256.58 ms | 401 KiB | 343 Q