3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "events": [{ "event_site_url": "https://www.yelp.com/events/london-the-european-information-security-summit-2017", "id": "london-the-european-information-security-summit-2017", "latitude": 51.5009690970451, "longitude": -0.119283199310303, "name": "The European Information Security Summit 2017", "time_start": "2018-02-21 17:00", "time_end": "2018-02-23 02:30" }] }'; $data = json_decode($json); $event = $data->events[0]; function get_nearest_timezone($cur_lat, $cur_long, $country_code = '') { $timezone_ids = ($country_code) ? DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, $country_code) : DateTimeZone::listIdentifiers(); if($timezone_ids && is_array($timezone_ids) && isset($timezone_ids[0])) { $time_zone = ''; $tz_distance = 0; //only one identifier? if (count($timezone_ids) == 1) { $time_zone = $timezone_ids[0]; } else { foreach($timezone_ids as $timezone_id) { $timezone = new DateTimeZone($timezone_id); $location = $timezone->getLocation(); $tz_lat = $location['latitude']; $tz_long = $location['longitude']; $theta = $cur_long - $tz_long; $distance = (sin(deg2rad($cur_lat)) * sin(deg2rad($tz_lat))) + (cos(deg2rad($cur_lat)) * cos(deg2rad($tz_lat)) * cos(deg2rad($theta))); $distance = acos($distance); $distance = abs(rad2deg($distance)); // echo '<br />'.$timezone_id.' '.$distance; if (!$time_zone || $tz_distance > $distance) { $time_zone = $timezone_id; $tz_distance = $distance; } } } return $time_zone; } return 'unknown'; } function getClosestTimezone($lat, $lng) { $diffs = array(); foreach(DateTimeZone::listIdentifiers() as $timezoneID) { $timezone = new DateTimeZone($timezoneID); $location = $timezone->getLocation(); $tLat = $location['latitude']; $tLng = $location['longitude']; $diffLat = abs($lat - $tLat); $diffLng = abs($lng - $tLng); $diff = $diffLat + $diffLng; $diffs[$timezoneID] = $diff; } //asort($diffs); $timezone = array_keys($diffs, min($diffs)); return $timezone[0]; } //timezone from co-ordinate $tz = getClosestTimezone($event->latitude, $event->longitude); //From: Wednesday, Feb 21, 9:00 am $date = DateTime::createFromFormat('Y-m-d H:i', $event->time_start, new DateTimeZone($tz)); echo 'From: '.$date->format('l, M j, g:m a') . "\n"; //To: Thursday, Feb 22, 6:30 pm $date = DateTime::createFromFormat('Y-m-d H:i', $event->time_end, new DateTimeZone($tz)); echo 'From: '.$date->format('l, M j, g:m a') . "\n";

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.0100.00618.80
8.3.50.0100.01016.96
8.3.40.0080.00819.42
8.3.30.0160.00719.45
8.3.20.0060.00320.71
8.3.10.0060.00322.19
8.3.00.0050.00322.23
8.2.180.0100.00618.54
8.2.170.0130.01019.83
8.2.160.0110.00722.96
8.2.150.0030.00625.66
8.2.140.0060.00324.66
8.2.130.0120.00326.16
8.2.120.0080.00021.05
8.2.110.0030.00721.16
8.2.100.0090.00418.78
8.2.90.0060.00320.23
8.2.80.0000.01018.63
8.2.70.0060.00618.63
8.2.60.0030.00720.13
8.2.50.0040.00419.22
8.2.40.0060.00322.32
8.2.30.0030.00620.04
8.2.20.0000.00819.03
8.2.10.0080.00018.87
8.2.00.0030.00619.02
8.1.280.0090.01925.92
8.1.270.0060.00322.43
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0060.00324.05
8.1.230.0030.00918.64
8.1.220.0000.01018.64
8.1.210.0000.01118.77
8.1.200.0030.00718.35
8.1.190.0080.00418.22
8.1.180.0060.00318.43
8.1.170.0000.00919.21
8.1.160.0030.00619.59
8.1.150.0050.00320.68
8.1.140.0000.00819.63
8.1.130.0040.00419.80
8.1.120.0030.00618.29
8.1.110.0030.00618.34
8.1.100.0000.00918.30
8.1.90.0060.00318.22
8.1.80.0040.00818.31
8.1.70.0030.00518.24
8.1.60.0050.00518.43
8.1.50.0030.00718.29
8.1.40.0030.00618.32
8.1.30.0000.01018.34
8.1.20.0030.00618.41
8.1.10.0030.00618.41
8.1.00.0000.00818.16
8.0.300.0070.01018.77
8.0.290.0070.00718.00
8.0.280.0030.01019.60
8.0.270.0090.00318.41
8.0.260.0150.00019.01
8.0.250.0060.00618.30
8.0.240.0060.00618.14
8.0.230.0030.00918.19
8.0.220.0090.00318.24
8.0.210.0000.01218.20
8.0.200.0080.00418.13
8.0.190.0060.00818.23
8.0.180.0090.00418.07
8.0.170.0030.00918.23
8.0.160.0030.00918.29
8.0.150.0000.01318.08
8.0.140.0060.00918.17
8.0.130.0040.00714.59
8.0.120.0000.01318.22
8.0.110.0070.00718.24
8.0.100.0060.00618.19
8.0.90.0060.00618.18
8.0.80.0090.01618.23
8.0.70.0060.00818.11
8.0.60.0030.01018.00
8.0.50.0060.00618.09
8.0.30.0120.01718.30
8.0.20.0110.01818.28
8.0.10.0030.01018.22
8.0.00.0120.01917.92
7.4.330.0000.00915.55
7.4.320.0030.00817.79
7.4.300.0000.01117.64
7.4.290.0000.01317.63
7.4.280.0000.01217.62
7.4.270.0040.01117.72
7.4.260.0030.00917.64
7.4.250.0030.00917.69
7.4.240.0000.01217.75
7.4.230.0000.01217.47
7.4.220.0100.01917.66
7.4.210.0000.02517.84
7.4.200.0000.01217.61
7.4.150.0160.02317.81
7.4.140.0100.01717.86
7.4.130.0090.01817.60
7.4.120.0120.02017.69
7.4.110.0130.02617.61
7.4.100.0060.02217.76
7.4.90.0130.01417.51
7.4.80.0040.02319.39
7.4.70.0070.02017.62
7.4.60.0130.01317.64
7.4.50.0100.01817.54
7.4.40.0150.02117.34
7.4.30.0130.01917.66
7.4.00.0080.02516.11
7.3.330.0030.00714.47
7.3.320.0000.01014.61
7.3.310.0000.01217.62
7.3.300.0030.00917.52
7.3.290.0120.01517.60
7.3.280.0070.01817.56
7.3.270.0160.01017.66
7.3.260.0110.02117.62
7.3.250.0130.01617.70
7.3.240.0100.02117.59
7.3.230.0070.02117.69
7.3.210.0120.01517.59
7.3.200.0100.01717.61
7.3.190.0110.01517.86
7.3.180.0100.01617.73
7.3.170.0130.01317.72
7.3.160.0040.02417.73
7.3.120.0130.01916.17
7.3.110.0150.02015.98
7.3.100.0020.02616.21
7.3.90.0100.02215.98
7.3.80.0020.02215.94
7.3.70.0070.01816.17
7.3.60.0100.01916.10
7.3.50.0090.01716.12
7.3.40.0080.02216.08
7.3.30.0080.01916.05
7.3.20.0060.02317.52
7.3.10.0080.01817.36
7.3.00.0080.02117.32
7.2.330.0060.02117.62
7.2.320.0070.02017.96
7.2.310.0030.02417.72
7.2.300.0130.01617.49
7.2.290.0120.01218.09
7.2.250.0130.02316.03
7.2.240.0050.02816.38
7.2.230.0030.02416.23
7.2.220.0070.02416.25
7.2.210.0070.02016.20
7.2.200.0050.02316.07
7.2.190.0080.02016.23
7.2.180.0070.01915.97
7.2.170.0080.01816.12
7.2.130.0130.01717.45
7.2.120.0000.03017.50
7.2.110.0100.01617.55
7.2.100.0030.02517.79
7.2.90.0810.01216.87
7.2.80.0090.01817.54
7.2.70.0080.01717.73
7.2.60.0100.01617.78
7.2.50.0030.02017.68
7.2.40.0110.01417.79
7.2.30.0090.01717.67
7.2.20.0050.01617.52
7.2.10.0080.01417.63
7.2.00.0050.01716.88
7.1.330.0050.01616.37
7.1.320.0060.01716.44
7.1.310.0050.01916.43
7.1.300.0020.01816.46
7.1.290.0030.01616.42
7.1.280.0070.01416.34
7.1.270.0070.01316.58
7.1.260.0020.02116.54
7.1.250.0030.02016.51
7.1.210.0070.01416.34
7.1.200.0070.01116.39
7.1.190.0040.01716.71
7.1.180.0150.00416.38
7.1.170.0270.01216.47
7.1.160.0040.01716.40
7.1.150.0130.01016.71
7.1.140.0150.00916.30
7.1.130.0090.01616.58
7.1.120.0030.01416.55
7.1.110.0070.01416.43
7.1.100.0110.00716.68
7.1.90.0120.01816.49
7.1.80.0030.01716.33
7.1.70.0130.00916.71
7.1.60.0310.02433.18
7.1.50.0210.01834.31
7.1.40.0180.02134.57
7.1.30.0200.02233.11
7.1.20.0170.02034.45
7.1.10.1200.00914.97
7.1.00.0040.02016.34
7.0.310.0110.00716.24
7.0.300.0000.02516.29
7.0.290.0040.01216.12
7.0.280.0030.02115.94
7.0.270.0070.01816.16
7.0.260.0070.01015.89
7.0.250.0050.01416.20
7.0.240.0060.01316.32
7.0.230.0170.01416.13
7.0.220.0040.02216.18
7.0.210.0000.02016.27
7.0.200.0060.01216.25
7.0.190.0120.01816.11
7.0.180.0140.01416.09
7.0.170.0070.01316.09
7.0.160.1580.01014.62
7.0.150.0110.00816.26
7.0.140.0040.01616.09
7.0.130.0110.01116.04
7.0.120.0100.01015.77
7.0.110.0030.01915.86
7.0.100.0060.02316.02
7.0.90.0030.02616.20
7.0.80.0120.01216.04
7.0.70.0110.01816.18
7.0.60.0070.01916.09
7.0.50.0100.01416.19
7.0.40.0140.01416.04
7.0.30.0110.01916.09
7.0.20.0130.01716.05
7.0.10.0120.01616.39
7.0.00.0100.01015.95

preferences:
56.86 ms | 400 KiB | 5 Q