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; } ?> Examples: <?php // 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.4.00.0110.00615.20
7.3.120.0120.00614.91
7.3.110.0110.00715.22
7.3.100.0070.01414.93
7.3.90.0060.00815.13
7.3.80.0050.00414.99
7.3.70.0030.00915.07
7.3.60.0120.00315.21
7.3.50.0090.00315.20
7.3.40.0090.00614.82
7.3.30.0140.00315.27
7.3.20.0110.00716.88
7.3.10.0070.00817.04
7.3.00.0090.00817.08
7.2.250.0160.00315.56
7.2.240.0120.00615.28
7.2.230.0060.00915.58
7.2.220.0110.00715.29
7.2.210.0070.01015.16
7.2.200.0090.00615.33
7.2.190.0030.01315.01
7.2.180.0130.00315.32
7.2.170.0070.01015.03
7.2.160.0070.01115.37
7.2.150.0170.00016.97
7.2.140.0080.00816.95
7.2.130.0070.00817.09
7.2.120.0030.01417.03
7.2.110.0100.00517.01
7.2.100.0080.01017.11
7.2.90.0070.00417.24
7.2.80.0050.01017.29
7.2.70.0050.00817.12
7.2.60.0050.00517.24
7.2.50.0050.01017.07
7.2.40.0060.00917.04
7.2.30.0040.00917.28
7.2.20.0050.01117.23
7.2.10.0120.00317.21
7.2.00.0040.00918.04
7.1.330.0110.00716.02
7.1.320.0130.00315.80
7.1.310.0100.00716.02
7.1.300.0070.00716.13
7.1.290.0000.01415.90
7.1.280.0110.00615.79
7.1.270.0070.01316.08
7.1.260.0130.00015.96
7.1.250.0050.00916.04
7.1.240.0090.01416.20
7.1.230.0030.01516.14
7.1.220.0110.00815.81
7.1.210.0090.00616.00
7.1.200.0000.01316.02
7.1.190.0030.01416.18
7.1.180.0080.00415.64
7.1.170.0070.00415.96
7.1.160.0030.01015.83
7.1.150.0060.00615.87
7.1.140.0030.00616.12
7.1.130.0130.00316.19
7.1.120.0040.01215.88
7.1.110.0070.01316.03
7.1.100.0070.00717.32
7.1.90.0060.00615.95
7.1.80.0060.01115.87
7.1.70.0310.00517.12
7.1.60.3200.00717.22
7.1.50.0320.00717.23
7.1.40.0320.01117.13
7.1.30.0310.01417.13
7.1.20.0310.00717.20
7.1.10.0490.00517.24
7.1.00.0340.00717.19
7.0.330.0070.01015.41
7.0.320.0040.01515.34
7.0.310.0040.00715.80
7.0.300.0070.01015.81
7.0.290.0050.00515.57
7.0.280.0030.01015.59
7.0.270.0040.01115.31
7.0.260.0070.01415.55
7.0.250.0060.01315.79
7.0.240.0060.00915.63
7.0.230.0030.01515.77
7.0.220.0070.00715.74
7.0.210.0080.00815.79
7.0.200.0300.00617.05
7.0.190.0300.00717.05
7.0.180.0370.00616.93
7.0.170.0410.00617.09
7.0.160.0290.00716.88
7.0.150.0300.00816.89
7.0.140.0420.00717.11
7.0.130.0240.00716.96
7.0.120.0250.00917.10
7.0.110.2420.01017.04
7.0.100.0290.00716.97
7.0.90.0410.00817.00
7.0.80.0340.00916.90
7.0.70.0350.00716.89
7.0.60.0320.00617.06
7.0.50.0320.00517.02
7.0.40.0050.00915.88
7.0.30.0070.01016.05
7.0.20.0070.00615.98
7.0.10.0050.00715.87
7.0.00.0040.00716.06
5.6.400.0110.00414.67
5.6.390.0210.00014.42
5.6.380.0030.01514.86
5.6.370.0060.00614.28
5.6.360.0100.01014.65
5.6.350.0100.00714.68
5.6.340.0110.00414.59
5.6.330.0000.00914.88
5.6.320.0070.01414.29
5.6.310.0120.00314.41
5.6.300.0100.02317.82
5.6.290.0040.02817.74
5.6.280.0020.03317.66
5.6.270.0000.04017.84
5.6.260.0170.04117.70
5.6.250.0110.03517.81
5.6.240.0140.04517.83
5.6.230.0080.02617.56
5.6.220.0100.03317.64
5.6.210.0090.02717.55
5.6.200.0100.02617.61
5.6.190.0090.02417.59
5.6.180.0120.02717.79
5.6.170.0050.02917.83
5.6.160.0100.02117.81
5.6.150.0050.04117.64
5.6.140.0070.02817.82
5.6.130.0030.03017.77
5.6.120.0050.02817.81
5.6.110.0060.03217.72
5.6.100.0050.02717.83
5.6.90.0100.02517.52
5.6.80.0070.02517.37
5.6.70.0060.02417.33
5.6.60.0050.02617.40
5.6.50.0080.02617.45
5.6.40.0100.02317.40
5.6.30.0100.02517.38
5.6.20.0110.02317.38
5.6.10.0070.03017.51
5.6.00.0090.03617.30
5.5.380.0070.02616.50
5.5.370.0090.02416.39
5.5.360.0010.03116.26
5.5.350.0030.03116.51
5.5.340.0100.02216.37
5.5.330.0090.02516.28
5.5.320.0050.02916.41
5.5.310.0050.02416.22
5.5.300.0130.02416.37
5.5.290.0090.02916.43
5.5.280.0060.02616.26
5.5.270.0080.02416.36
5.5.260.0050.02716.32
5.5.250.0050.02416.42
5.5.240.0000.02916.28
5.5.230.0050.02816.40
5.5.220.0030.02816.27
5.5.210.0050.02516.38
5.5.200.0050.02316.23
5.5.190.0090.02116.39
5.5.180.0040.02616.42
5.5.170.0000.01314.36
5.5.160.0050.02716.39
5.5.150.0100.02216.36
5.5.140.0030.02916.47
5.5.130.0080.02216.48
5.5.120.0030.02616.36
5.5.110.0030.02616.43
5.5.100.0100.02216.39
5.5.90.0100.02116.44
5.5.80.0070.02216.38
5.5.70.0110.03216.42
5.5.60.0050.02616.31
5.5.50.0130.01816.43
5.5.40.0020.03416.45
5.5.30.0090.02216.44
5.5.20.0050.02516.33
5.5.10.0090.02216.37
5.5.00.0050.02616.44
5.4.450.0080.02615.31
5.4.440.0150.02515.13
5.4.430.0040.02415.32
5.4.420.0030.02615.39
5.4.410.0100.02015.30
5.4.400.0090.02014.96
5.4.390.0080.01915.24
5.4.380.0100.02115.08
5.4.370.0040.02715.20
5.4.360.0060.02514.85
5.4.350.0050.02514.97
5.4.340.0030.02814.88
5.4.330.0000.01111.18
5.4.320.0050.02415.03
5.4.310.0060.02315.24
5.4.300.0040.02515.07
5.4.290.0060.02515.20
5.4.280.0100.02115.03
5.4.270.0060.02015.03
5.4.260.0050.02215.18
5.4.250.0050.02514.98
5.4.240.0050.02315.01
5.4.230.0050.02615.21
5.4.220.0090.02015.09
5.4.210.0090.02015.01
5.4.200.0050.03215.03
5.4.190.0080.02215.15
5.4.180.0060.02415.10
5.4.170.0040.02215.12
5.4.160.0060.02115.20
5.4.150.0090.02115.12
5.4.140.0050.02114.65
5.4.130.0060.01914.73
5.4.120.0050.02214.79
5.4.110.0070.02414.71
5.4.100.0060.02014.78
5.4.90.0080.02114.73
5.4.80.0080.02314.69
5.4.70.0080.02014.64
5.4.60.0070.02214.83
5.4.50.0080.02114.87
5.4.40.0030.02614.82
5.4.30.0080.02114.82
5.4.20.0080.02214.79
5.4.10.0040.02514.73
5.4.00.0050.02514.63
5.3.290.0060.02114.63
5.3.280.0050.02314.57
5.3.270.0060.02414.46
5.3.260.0070.02214.69
5.3.250.0060.02114.61
5.3.240.0040.02514.44
5.3.230.0040.02314.64
5.3.220.0020.03114.47
5.3.210.0150.01514.56
5.3.200.0000.02814.50
5.3.190.0070.02314.51
5.3.180.0050.02114.63
5.3.170.0120.02514.47
5.3.160.0030.02514.54
5.3.150.0050.02814.45
5.3.140.0050.02214.45
5.3.130.0090.02114.56
5.3.120.0090.02414.45
5.3.110.0220.02214.53
5.3.100.0050.02714.63
5.3.90.0050.02314.51
5.3.80.0020.02714.52
5.3.70.0050.02514.52
5.3.60.0040.02514.57
5.3.50.0070.02214.59
5.3.40.0000.02714.52
5.3.30.0050.02214.65
5.3.20.0050.02314.54
5.3.10.0100.01914.51
5.3.00.0020.02514.46
5.2.170.0000.03618.33
5.2.160.0000.03618.33
5.2.150.0030.03118.33
5.2.140.0070.03318.33
5.2.130.0040.03218.33
5.2.120.0110.02218.33
5.2.110.0030.03618.33
5.2.100.0090.02818.33
5.2.90.0070.03018.33
5.2.80.0090.02818.33
5.2.70.0030.03618.33
5.2.60.0000.03918.33
5.2.50.0060.03418.33
5.2.40.0070.02818.33
5.2.30.0040.03218.33
5.2.20.0040.02918.33
5.2.10.0060.03118.33
5.2.00.0030.03518.33
5.1.60.0090.01918.33
5.1.50.0060.02518.33
5.1.40.0000.03018.33
5.1.30.0000.03318.33
5.1.20.0110.02218.33
5.1.10.0040.02618.33
5.1.00.0040.02518.33
5.0.50.0040.02318.33
5.0.40.0000.02618.33
5.0.30.0030.03318.33
5.0.20.0040.02518.33
5.0.10.0070.01818.33
5.0.00.0000.03318.33
4.4.90.0040.01618.33
4.4.80.0000.01918.33
4.4.70.0000.02018.33
4.4.60.0060.01718.33
4.4.50.0000.02018.33
4.4.40.0000.03018.33
4.4.30.0040.01418.33
4.4.20.0000.02018.33
4.4.10.0050.01618.33
4.4.00.0030.02718.33
4.3.110.0040.01818.33
4.3.100.0000.01918.33
4.3.90.0040.01518.33
4.3.80.0000.02818.33
4.3.70.0030.01618.33
4.3.60.0000.01818.33
4.3.50.0030.01918.33
4.3.40.0000.02618.33
4.3.30.0040.02518.33
4.3.20.0000.01718.33
4.3.10.0000.01718.33
4.3.00.0030.01618.33

preferences:
41.36 ms | 400 KiB | 5 Q