3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TimeZone { const NO_TIMEZONE = 0; const ASIA_YEKATERINBURG = 310; const EUROPE_KALININGRAD = 390; const EUROPE_MOSCOW = 401; const EUROPE_SAMARA = 409; const ROC = 492; const ROK = 493; const UCT = 494; const UTC = 495; const WET = 496; /** * list of time zones */ public static $constToFullName = array( self::ASIA_YEKATERINBURG => 'Asia/Yekaterinburg', self::EUROPE_KALININGRAD => 'Europe/Kaliningrad', self::EUROPE_MOSCOW => 'Europe/Moscow', self::EUROPE_SAMARA => 'Europe/Samara', ); /** * list of time zones indexed by name */ public static $fullNameToConst = array( 'Europe/Kaliningrad' => self::EUROPE_KALININGRAD, 'Europe/Moscow' => self::EUROPE_MOSCOW, 'Europe/Samara' => self::EUROPE_SAMARA, ); /** * Get time zone string based on constant value * * @param int $const * * @return string|null */ public static function get($const) { if (isset(static::$constToFullName[$const])) { return static::$constToFullName[$const]; } else { return null; } } /** * Get time zone constant value from passed time zone string * * @param int $code * * @return int|null */ public static function findByFullName($code) { if (isset(static::$fullNameToConst[$code])) { return static::$fullNameToConst[$code]; } else { return null; } } /** * Check if constant exists * * @param int $const * * @return bool */ public static function isConst($const) { return isset(static::$constToFullName[$const]); } /** * Get time zone constant value from passed time zone string * * @param string $timeZoneString * * @return bool */ public static function isTimeZone($timeZoneString) { return isset(static::$fullNameToConst[$timeZoneString]); } } const TIME_ZONE_FORMAT_NAME = 'utc'; $TIME_ZONE_FORMAT_NAME = 'utc'; $KEY_VALUE = 'value'; $KEY_NAME = 'name'; $KEY_OFFSET = 'offset'; $KEY_FORMAT = 'format'; $KEY_DISPLAY = 'display'; function convertTimezoneToArray($timezone, $value) { $dateTime = new \DateTime(); $dateTime->setTimeZone(new \DateTimeZone($timezone)); return [ $KEY_VALUE => $value, $KEY_NAME => $timezone, $KEY_OFFSET => $dateTime->format('P'), $KEY_FORMAT => $TIME_ZONE_FORMAT_NAME ]; } 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);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0110.00416.63
8.3.50.0050.00921.27
8.3.40.0070.00719.09
8.3.30.0160.00019.01
8.3.20.0040.00420.33
8.3.10.0030.00523.65
8.3.00.0040.00421.96
8.2.180.0130.00318.54
8.2.170.0070.00722.96
8.2.160.0100.00320.43
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0050.00320.94
8.2.120.0100.00026.35
8.2.110.0100.00019.21
8.2.100.0000.01218.05
8.2.90.0040.00419.34
8.2.80.0050.00318.00
8.2.70.0070.00318.00
8.2.60.0000.00818.05
8.2.50.0080.00318.09
8.2.40.0030.00622.13
8.2.30.0050.00219.57
8.2.20.0030.00618.14
8.2.10.0060.00318.34
8.2.00.0000.00818.38
8.1.280.0040.01125.92
8.1.270.0120.00622.11
8.1.260.0040.00428.09
8.1.250.0080.00028.09
8.1.240.0060.00322.58
8.1.230.0090.00317.83
8.1.220.0080.00017.91
8.1.210.0060.00318.77
8.1.200.0030.01217.63
8.1.190.0000.00817.60
8.1.180.0080.00018.10
8.1.170.0060.00318.78
8.1.160.0040.00420.84
8.1.150.0030.00619.11
8.1.140.0040.00419.66
8.1.130.0070.00017.79
8.1.120.0000.00817.66
8.1.110.0070.00017.61
8.1.100.0000.00917.70
8.1.90.0040.00417.64
8.1.80.0050.00317.62
8.1.70.0000.00717.59
8.1.60.0040.00417.77
8.1.50.0000.00917.63
8.1.40.0030.00517.65
8.1.30.0030.00617.70
8.1.20.0030.00717.76
8.1.10.0060.00317.73
8.1.00.0040.00417.77
8.0.300.0000.00818.77
8.0.290.0000.00817.00
8.0.280.0000.00718.73
8.0.270.0030.00317.47
8.0.260.0000.00717.46
8.0.250.0020.00517.26
8.0.240.0030.00317.37
8.0.230.0030.00317.41
8.0.220.0030.00317.36
8.0.210.0040.00417.29
8.0.200.0030.00517.34
8.0.190.0050.00217.36
8.0.180.0040.00417.38
8.0.170.0040.00417.36
8.0.160.0000.00817.34
8.0.150.0070.00417.26
8.0.140.0030.00717.23
8.0.130.0000.00813.59
8.0.120.0030.00617.25
8.0.110.0040.00417.26
8.0.100.0040.00417.34
8.0.90.0050.00317.11
8.0.80.0070.01017.26
8.0.70.0000.00817.10
8.0.60.0000.00817.21
8.0.50.0000.00817.11
8.0.30.0100.00817.30
8.0.20.0120.00717.43
8.0.10.0090.00017.20
8.0.00.0090.01117.08
7.4.330.0020.00216.66
7.4.320.0000.00716.67
7.4.300.0040.00416.65
7.4.290.0080.00416.80
7.4.280.0000.00716.65
7.4.270.0030.00316.74
7.4.260.0040.00416.66
7.4.250.0070.00016.66
7.4.240.0030.00616.80
7.4.230.0000.00716.57
7.4.220.0060.01216.85
7.4.210.0110.00416.76
7.4.200.0040.00416.80
7.4.160.0120.00916.91
7.4.150.0130.00617.40
7.4.140.0140.01017.86
7.4.130.0130.00916.89
7.4.120.0070.01216.81
7.4.110.0070.01316.64
7.4.100.0130.00316.71
7.4.90.0090.01616.82
7.4.80.0130.01019.39
7.4.70.0110.00616.81
7.4.60.0100.01016.87
7.4.50.0090.00316.73
7.4.40.0040.01316.77
7.4.30.0140.01816.69
7.4.00.0040.01415.40
7.3.330.0000.00513.66
7.3.320.0000.00613.43
7.3.310.0000.00716.55
7.3.300.0070.00016.70
7.3.290.0110.01016.66
7.3.280.0060.01216.66
7.3.270.0030.01517.40
7.3.260.0120.01316.93
7.3.250.0120.00716.72
7.3.240.0060.01116.84
7.3.230.0070.01016.81
7.3.210.0170.00016.86
7.3.200.0110.00719.39
7.3.190.0060.01616.95
7.3.180.0120.00616.73
7.3.170.0160.00616.80
7.3.160.0080.00916.81
7.2.330.0070.01116.97
7.2.320.0090.00916.92
7.2.310.0130.01116.86
7.2.300.0130.01016.60
7.2.290.0050.01117.16
7.2.60.0070.00817.18
7.2.00.0000.01119.56
7.1.200.0040.01215.81
7.1.100.0380.00318.16
7.1.70.0040.00417.47
7.1.60.0030.02219.40
7.1.50.0070.01417.31
7.1.00.0030.07722.45
7.0.200.0390.00314.96
7.0.60.0300.05020.05
7.0.50.0070.04717.91
7.0.40.0130.08020.29
7.0.30.0170.04320.34
7.0.20.0270.06320.01
7.0.10.0000.08320.15
7.0.00.0100.05720.09
5.6.280.0000.05320.93
5.6.210.0000.09320.74
5.6.200.0100.06018.21
5.6.190.0100.07720.42
5.6.180.0270.05320.48
5.6.170.0230.06720.44
5.6.160.0000.04720.54
5.6.150.0100.05718.19
5.6.140.0070.08018.22
5.6.130.0100.05718.19
5.6.120.0100.06721.01
5.6.110.0100.08721.00
5.6.100.0070.04720.98
5.6.90.0070.08720.99
5.6.80.0070.03320.44
5.5.350.0100.07720.35
5.5.340.0100.08018.05
5.5.330.0100.07720.21
5.5.320.0670.06320.28
5.5.310.0200.04320.51
5.5.300.0130.03317.96
5.5.290.0070.03717.93
5.5.280.0100.04720.82
5.5.270.0130.07720.86
5.5.260.0170.07720.89
5.5.250.0070.05020.56
5.5.240.0230.04320.15

preferences:
54.01 ms | 401 KiB | 5 Q