3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** Returns the offset from the origin timezone to the remote timezone, in seconds. * @param $remote_tz; * @param $origin_tz; If null the servers current timezone is used as the origin. * @return int; */ function get_timezone_offset($remote_tz, $origin_tz = null) { if($origin_tz === null) { if(!is_string($origin_tz = date_default_timezone_get())) { return false; // A UTC timestamp was returned -- bail out! } } $origin_dtz = new DateTimeZone($origin_tz); $remote_dtz = new DateTimeZone($remote_tz); $origin_dt = new DateTime("now", $origin_dtz); $remote_dt = new DateTime("now", $remote_dtz); $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt); return $offset; } // This will return 10800 (3 hours) ... $offset = get_timezone_offset('America/Los_Angeles','America/New_York'); // or, if your server time is already set to 'America/New_York'... $offset = get_timezone_offset('America/Los_Angeles'); // You can then take $offset and adjust your timestamp. $offset_time = time() + $offset; ?>

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)
7.2.00.0000.01419.77
7.1.100.0000.01418.11
7.1.70.0030.00717.47
7.1.60.0040.01119.17
7.1.50.0000.01117.11
7.1.00.0030.03322.44
7.0.200.0100.00717.05
7.0.140.0100.06021.96
7.0.90.0030.04319.86
7.0.80.0300.04719.86
7.0.70.0370.03319.82
7.0.60.0470.07719.93
7.0.50.0430.05320.25
7.0.40.0170.03720.08
7.0.30.0100.07720.07
7.0.20.0070.06020.11
7.0.10.0000.07320.13
7.0.00.0100.07019.94
5.6.280.0070.07021.11
5.6.240.0070.04020.61
5.6.230.0070.06020.57
5.6.220.0130.07720.61
5.6.210.0170.07020.41
5.6.200.0130.07720.94
5.6.190.0070.08321.18
5.6.180.0100.08321.03
5.6.170.0130.06721.17
5.6.160.0070.08321.05
5.6.150.0100.04020.95
5.6.140.0170.05721.07
5.6.130.0100.08021.06
5.6.120.0130.07021.07
5.6.110.0030.07721.13
5.6.100.0070.07021.01
5.6.90.0030.06021.03
5.6.80.0130.04020.47
5.6.70.0070.06720.46
5.6.60.0070.08320.42
5.6.50.0000.05020.41
5.6.40.0070.04320.43
5.6.30.0130.07020.32
5.6.20.0070.07020.39
5.6.10.0100.04320.37
5.6.00.0000.05320.29
5.5.380.0100.07720.35
5.5.370.0070.06720.36
5.5.360.0030.04020.29
5.5.350.0130.07320.41
5.5.340.0070.04020.88
5.5.330.0170.06320.79
5.5.320.0030.05320.93
5.5.310.0100.05720.76
5.5.300.0130.04320.64
5.5.290.0170.06720.90
5.5.280.0130.04320.91
5.5.270.0100.08720.82
5.5.260.0130.07720.89
5.5.250.0070.06720.71
5.5.240.0000.08020.19
5.5.230.0130.07320.20
5.5.220.0030.05020.30
5.5.210.0100.03320.12
5.5.200.0170.06720.11
5.5.190.0030.04720.13
5.5.180.0070.06720.00
5.5.160.0070.07720.22
5.5.150.0000.07020.27
5.5.140.0030.06020.12
5.5.130.0100.08320.27
5.5.120.0070.08320.24
5.5.110.0100.07720.26
5.5.100.0070.09020.11
5.5.90.0030.04719.97
5.5.80.0100.06020.07
5.5.70.0100.07720.09
5.5.60.0100.07020.14
5.5.50.0070.06320.00
5.5.40.0030.07719.97
5.5.30.0100.07319.93
5.5.20.0030.08720.08
5.5.10.0030.09020.00
5.5.00.0030.07319.97
5.4.450.0170.07719.36
5.4.440.0030.08319.18
5.4.430.0070.06319.22
5.4.420.0100.07019.48
5.4.410.0070.07319.38
5.4.400.0030.04718.88
5.4.390.0030.07719.14
5.4.380.0000.07719.12
5.4.370.0130.07719.13
5.4.360.0130.06719.05
5.4.350.0070.07719.23
5.4.340.0070.06719.13
5.4.320.0100.07319.18
5.4.310.0030.08019.03
5.4.300.0100.07718.94
5.4.290.0070.03319.03
5.4.280.0070.06319.12
5.4.270.0000.03719.18
5.4.260.0000.04719.12
5.4.250.0070.04318.90
5.4.240.0070.06019.21
5.4.230.0100.07018.84
5.4.220.0170.06719.22
5.4.210.0130.07019.03
5.4.200.0170.07319.04
5.4.190.0070.07018.88
5.4.180.0100.07019.14
5.4.170.0000.08019.03
5.4.160.0030.07719.07
5.4.150.0030.08319.07
5.4.140.0070.07316.44
5.4.130.0000.07716.40
5.4.120.0100.07016.39
5.4.110.0070.05016.27
5.4.100.0130.06716.36
5.4.90.0070.05016.43
5.4.80.0070.06316.26
5.4.70.0000.06316.37
5.4.60.0100.06316.45
5.4.50.0000.04316.45
5.4.40.0100.04016.35
5.4.30.0030.03716.41
5.4.20.0030.08016.46
5.4.10.0100.07716.53
5.4.00.0130.05715.91
5.3.290.0030.06314.71
5.3.280.0070.04014.54
5.3.270.0130.07714.74
5.3.260.0100.06714.66
5.3.250.0070.07014.66
5.3.240.0130.06714.70
5.3.230.0130.07314.55
5.3.220.0070.07314.63
5.3.210.0070.04314.49
5.3.200.0030.08014.65
5.3.190.0000.06714.66
5.3.180.0070.04014.48
5.3.170.0070.07014.62
5.3.160.0130.07714.63
5.3.150.0000.07314.62
5.3.140.0070.03314.58
5.3.130.0070.04014.62
5.3.120.0030.05014.52
5.3.110.0100.07714.55
5.3.100.0000.04713.96
5.3.90.0030.07014.08
5.3.80.0030.07313.94
5.3.70.0030.06314.13
5.3.60.0100.05014.07
5.3.50.0130.07713.94
5.3.40.0000.05014.01
5.3.30.0000.07313.83
5.3.20.0100.04313.75
5.3.10.0000.04713.76
5.3.00.0100.07013.66
5.2.170.0100.03711.28
5.2.160.0000.04011.06
5.2.150.0030.06711.05
5.2.140.0100.05311.07
5.2.130.0070.04711.19
5.2.120.0130.05011.15
5.2.110.0070.05010.98
5.2.100.0070.05711.16
5.2.90.0030.05011.04
5.2.80.0100.06011.16
5.2.70.0000.06311.13
5.2.60.0100.06011.04
5.2.50.0070.04711.12
5.2.40.0030.03011.00
5.2.30.0070.02711.01
5.2.20.0070.03310.95
5.2.10.0030.05710.98
5.2.00.0030.04310.73
5.1.60.0030.04010.51
5.1.50.0100.04710.51
5.1.40.0070.02010.51
5.1.30.0030.03710.51
5.1.20.0030.03010.51
5.1.10.0070.05310.51
5.1.00.0000.04310.51
5.0.50.0000.03710.51
5.0.40.0000.03710.51
5.0.30.0070.04310.51
5.0.20.0100.02310.51
5.0.10.0000.02310.51
5.0.00.0030.04010.51
4.4.90.0000.03710.51
4.4.80.0000.03710.51
4.4.70.0030.03310.51
4.4.60.0000.02010.51
4.4.50.0000.02310.51
4.4.40.0000.05310.51
4.4.30.0030.01310.51
4.4.20.0030.03310.51
4.4.10.0030.03710.51
4.4.00.0030.02310.51
4.3.110.0030.03010.51
4.3.100.0070.02710.51
4.3.90.0030.01710.51
4.3.80.0130.03010.51
4.3.70.0000.01710.51
4.3.60.0030.01710.51
4.3.50.0070.01310.51
4.3.40.0030.05310.51
4.3.30.0070.01710.51
4.3.20.0030.03010.51
4.3.10.0030.03310.51
4.3.00.0030.01310.51

preferences:
37.94 ms | 401 KiB | 5 Q