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 git.master, git.master_jit, rfc.property-hooks
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) } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
40.48 ms | 402 KiB | 8 Q