3v4l.org

run code in 300+ PHP versions simultaneously
<?php function align_timestamp_to($stamp, $unit, $past){ // timestamp, unit string, start/end static $modes = array( 'year' => 'last year', 'week' => 'last monday', 'month' => 'first day of this month', 'hour' => 'last hour', 'minute' => 'last minute', ); // TODO error out if unknown $unit $offset = $modes[$unit]; if($past == 'end')$offset = '+1 '.$unit.' '.$offset.' -1 second'; return strtotime($offset, $stamp); } foreach(array( array(strtotime('4 Apr 2012'), 'year', 'start'), array(strtotime('4 Apr 2012'), 'year', 'end'), array(strtotime('4 Apr 2012'), 'month', 'start'), array(strtotime('4 Apr 2012'), 'month', 'end'), array(strtotime('4 Apr 2012'), 'week', 'start'), array(strtotime('4 Apr 2012'), 'week', 'end'), ) as $test)echo date('r', $test[0]).' aligned '.$test[2].' of '.$test[1].' yields '.date('r', align_timestamp_to($test[0], $test[1], $test[2])).PHP_EOL;

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.0090.00918.61
8.3.50.0080.00921.09
8.3.40.0190.00319.05
8.3.30.0090.00618.76
8.3.20.0040.00418.90
8.3.10.0040.00421.14
8.3.00.0040.00423.50
8.2.180.0070.00716.88
8.2.170.0120.00322.96
8.2.160.0130.00020.35
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00419.90
8.2.110.0040.00720.50
8.2.100.0080.00318.09
8.2.90.0040.00419.33
8.2.80.0000.00818.29
8.2.70.0030.00617.88
8.2.60.0040.00418.16
8.2.50.0000.00818.07
8.2.40.0030.00518.47
8.2.30.0040.00421.36
8.2.20.0040.00418.01
8.2.10.0030.00618.07
8.2.00.0030.00517.96
8.1.280.0100.00725.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0100.01022.67
8.1.230.0080.00420.99
8.1.220.0000.00818.77
8.1.210.0000.00818.89
8.1.200.0040.00417.50
8.1.190.0030.00619.31
8.1.180.0000.00818.10
8.1.170.0050.00318.82
8.1.160.0040.00419.09
8.1.150.0040.00418.96
8.1.140.0000.00817.65
8.1.130.0000.00717.86
8.1.120.0000.00717.78
8.1.110.0100.00017.77
8.1.100.0000.00717.74
8.1.90.0000.00717.69
8.1.80.0050.00217.66
8.1.70.0000.00717.74
8.1.60.0080.00017.77
8.1.50.0040.00417.55
8.1.40.0080.00017.75
8.1.30.0050.00317.87
8.1.20.0080.00017.86
8.1.10.0060.00317.71
8.1.00.0040.00417.82
8.0.300.0040.00420.14
8.0.290.0020.00517.28
8.0.280.0000.00718.71
8.0.270.0070.00317.48
8.0.260.0030.00317.12
8.0.250.0000.00817.21
8.0.240.0050.00317.14
8.0.230.0030.00317.24
8.0.220.0030.00617.19
8.0.210.0050.00317.16
8.0.200.0000.00717.21
8.0.190.0040.00417.22
8.0.180.0040.00417.24
8.0.170.0040.00417.12
8.0.160.0040.00417.14
8.0.150.0000.00717.18
8.0.140.0000.00717.06
8.0.130.0000.00613.47
8.0.120.0050.00317.12
8.0.110.0040.00417.05
8.0.100.0040.00417.20
8.0.90.0040.00417.06
8.0.80.0080.00817.14
8.0.70.0040.00417.20
8.0.60.0070.00017.16
8.0.50.0050.00217.21
8.0.30.0090.01117.15
8.0.20.0130.01217.42
8.0.10.0040.00417.30
8.0.00.0100.00717.04
7.4.330.0000.00514.98
7.4.320.0000.00616.85
7.4.300.0030.00316.72
7.4.290.0000.00816.83
7.4.280.0000.00816.61
7.4.270.0000.00716.74
7.4.260.0000.00513.45
7.4.250.0080.00016.61
7.4.240.0040.00416.84
7.4.230.0000.00716.57
7.4.220.0100.01316.74
7.4.210.0100.00716.84
7.4.200.0000.00716.89
7.4.190.0030.00516.89
7.4.160.0030.01316.82
7.4.150.0030.01517.40
7.4.140.0190.00117.86
7.4.130.0090.00916.78
7.4.120.0090.01016.78
7.4.110.0060.01316.80
7.4.100.0060.01416.67
7.4.90.0090.01216.80
7.4.80.0120.00619.37
7.4.70.0070.01116.93
7.4.60.0000.01616.79
7.4.50.0030.00616.45
7.4.40.0060.01022.52
7.4.30.0110.00616.94
7.4.00.0040.01215.08
7.3.330.0030.00313.41
7.3.320.0050.00013.61
7.3.310.0000.00716.62
7.3.300.0070.00016.40
7.3.290.0120.00916.51
7.3.280.0090.00616.50
7.3.270.0090.01617.40
7.3.260.0140.00818.24
7.3.250.0070.01016.81
7.3.240.0160.00016.71
7.3.230.0090.01216.76
7.3.210.0060.01216.73
7.3.200.0150.00319.39
7.3.190.0080.01316.65
7.3.180.0080.00816.70
7.3.170.0100.00716.88
7.3.160.0060.01016.61
7.3.120.0110.00715.04
7.3.110.0100.00715.01
7.3.100.0030.01314.94
7.3.90.0080.00415.13
7.3.80.0040.00714.71
7.3.70.0140.00015.09
7.3.60.0070.00715.22
7.3.50.0000.01314.86
7.3.40.0030.01015.07
7.3.30.0030.00914.89
7.3.20.0060.00316.87
7.3.10.0080.00516.89
7.3.00.0090.00616.78
7.2.330.0090.00917.18
7.2.320.0090.01316.82
7.2.310.0140.00916.97
7.2.300.0110.00516.85
7.2.290.0120.00916.97
7.2.240.0030.01315.25
7.2.230.0000.01415.37
7.2.220.0060.00615.48
7.2.210.0120.00315.31
7.2.200.0080.00315.34
7.2.190.0040.00815.21
7.2.180.0030.00715.32
7.2.170.0030.00615.46
7.2.160.0070.00715.42
7.2.150.0060.00917.23
7.2.140.0070.00717.27
7.2.130.0070.00617.12
7.2.120.0070.00717.10
7.2.110.0070.00817.16
7.2.100.0070.00817.19
7.2.90.0080.00817.23
7.2.80.0040.00717.22
7.2.70.0090.00817.25
7.2.60.0080.00517.27
7.2.50.0030.00917.12
7.2.40.0060.01217.15
7.2.30.0040.01117.23
7.2.20.0100.00617.28
7.2.10.0100.00816.99
7.2.00.0160.00817.93
7.1.330.0080.00816.15
7.1.320.0100.00016.12
7.1.310.0070.01015.81
7.1.300.0090.00916.18
7.1.290.0060.00316.14
7.1.280.0120.00015.96
7.1.270.0040.00415.95
7.1.260.0000.01615.88
7.1.250.0050.00816.08
7.1.200.0030.01015.99
7.1.100.0090.00618.36
7.1.70.0030.00517.46
7.1.60.0060.01219.40
7.1.50.0100.01017.30
7.1.00.0070.04022.35
7.0.200.0040.00416.54
7.0.140.0000.07721.97
7.0.100.0030.08319.98
7.0.90.0230.06319.89
7.0.80.0100.08719.92
7.0.70.0130.07720.15
7.0.60.0130.08019.80
7.0.50.0170.06020.26
7.0.40.0130.05720.07
7.0.30.0070.06320.17
7.0.20.0070.05720.05
7.0.10.0100.04020.03
7.0.00.0070.07720.07
5.6.280.0030.07320.78
5.6.250.0030.09020.73
5.6.240.0100.06020.53
5.6.230.0100.04720.75
5.6.220.0070.07320.72
5.6.210.0130.08720.72
5.6.200.0100.07321.13
5.6.190.0030.04721.06
5.6.180.0130.07321.12
5.6.170.0100.09321.18
5.6.160.0070.05021.01
5.6.150.0070.06721.12
5.6.140.0070.04321.14
5.6.130.0100.04720.96
5.6.120.0000.07721.12
5.6.110.0100.07021.05
5.6.100.0030.08021.14
5.6.90.0070.08021.12
5.6.80.0070.08020.35
5.6.70.0130.08020.41
5.6.60.0000.07020.38
5.6.50.0130.07720.36
5.6.40.0070.08720.45
5.6.30.0100.07720.46
5.6.20.0070.06720.33
5.6.10.0070.06320.30
5.6.00.0000.04720.31
5.5.380.0100.07720.50
5.5.370.0170.06720.38
5.5.360.0070.07320.50
5.5.350.0100.08020.43
5.5.340.0070.04720.81
5.5.330.0130.05720.84
5.5.320.0230.07320.75
5.5.310.0070.07720.80
5.5.300.0100.06020.77
5.5.290.0070.06320.79
5.5.280.0130.07320.84
5.5.270.0130.07720.75
5.5.260.0130.07720.78
5.5.250.0070.07720.68
5.5.240.0070.08020.23
5.5.230.0100.07320.18
5.5.220.0030.04320.27
5.5.210.0030.04720.12
5.5.200.0070.04320.19
5.5.190.0000.09020.25
5.5.180.0070.08020.25
5.5.160.0170.07720.12
5.5.150.0070.04020.25
5.5.140.0100.07720.29
5.5.130.0100.07320.19
5.5.120.0130.07320.27
5.5.110.0030.06720.28
5.5.100.0070.08320.06
5.5.90.0070.05720.08
5.5.80.0130.07019.99
5.5.70.0100.05020.08
5.5.60.0000.09320.05
5.5.50.0070.07720.16
5.5.40.0070.06720.10
5.5.30.0000.06320.04
5.5.20.0130.06720.12
5.5.10.0000.08719.99
5.5.00.0130.07020.03
5.4.450.0130.07319.45
5.4.440.0130.08019.45
5.4.430.0100.08019.50
5.4.420.0030.05019.35
5.4.410.0130.03019.14
5.4.400.0100.07319.18
5.4.390.0030.05019.09
5.4.380.0170.05718.95
5.4.370.0070.04319.05
5.4.360.0170.06719.16
5.4.350.0000.05718.90
5.4.340.0100.07719.05
5.4.320.0070.08719.03
5.4.310.0030.04319.21
5.4.300.0100.06019.18
5.4.290.0130.05319.16
5.4.280.0100.07319.23
5.4.270.0100.07319.04
5.4.260.0130.03719.09
5.4.250.0100.05319.04
5.4.240.0070.04718.89
5.4.230.0030.06718.89
5.4.220.0100.06719.04
5.4.210.0170.06319.08
5.4.200.0100.07319.04
5.4.190.0070.07018.86
5.4.180.0030.07319.20
5.4.170.0030.07719.01
5.4.160.0000.07318.93
5.4.150.0070.07718.93
5.4.140.0030.07716.41
5.4.130.0000.06716.41
5.4.120.0000.04316.42
5.4.110.0100.07016.51
5.4.100.0100.03716.53
5.4.90.0170.05016.50
5.4.80.0070.06016.47
5.4.70.0070.04316.50
5.4.60.0100.07316.25
5.4.50.0130.06716.44
5.4.40.0100.06016.41
5.4.30.0000.07316.40
5.4.20.0070.07316.36
5.4.10.0030.05016.29
5.4.00.0070.07015.86
5.3.290.0030.04314.61
5.3.280.0100.07714.61
5.3.270.0030.04314.67
5.3.260.0030.07314.63
5.3.250.0170.02714.63
5.3.240.0070.07314.55
5.3.230.0100.03714.64
5.3.220.0070.07714.55
5.3.210.0070.08014.57
5.3.200.0070.04714.64
5.3.190.0100.07314.68
5.3.180.0030.05014.55
5.3.170.0070.04314.66
5.3.160.0100.07014.67
5.3.150.0100.07314.55
5.3.140.0170.06314.59
5.3.130.0030.05714.62
5.3.120.0030.06714.57
5.3.110.0070.05314.65
5.3.100.0130.06314.07
5.3.90.0130.06714.05
5.3.80.0070.06314.09
5.3.70.0030.07713.96
5.3.60.0000.07313.93
5.3.50.0100.07013.95
5.3.40.0130.05714.02
5.3.30.0000.05313.98
5.3.20.0100.05713.74
5.3.10.0030.06313.71
5.3.00.0000.07013.63
5.2.170.0070.05711.06
5.2.160.0000.06711.02
5.2.150.0070.05711.29
5.2.140.0070.06311.26
5.2.130.0070.06011.16
5.2.120.0070.06010.97
5.2.110.0070.05311.14
5.2.100.0070.05711.23
5.2.90.0000.06711.17
5.2.80.0070.06311.13
5.2.70.0030.06711.14
5.2.60.0100.05711.07
5.2.50.0000.06711.02
5.2.40.0030.05711.14
5.2.30.0070.03311.03
5.2.20.0070.05710.92
5.2.10.0100.05310.80
5.2.00.0070.04310.68
5.1.60.0070.04710.01
5.1.50.0070.05310.00
5.1.40.0070.05010.08
5.1.30.0070.05710.28
5.1.20.0030.05010.49
5.1.10.0030.0409.94
5.1.00.0070.04710.18
5.0.50.0030.0278.55
5.0.40.0070.0378.50
5.0.30.0030.0608.08
5.0.20.0030.0438.10
5.0.10.0070.0438.03
5.0.00.0030.0538.25
4.4.90.0000.0337.18
4.4.80.0030.0307.18
4.4.70.0070.0337.18
4.4.60.0000.0407.18
4.4.50.0070.0277.18
4.4.40.0070.0477.18
4.4.30.0000.0407.18
4.4.20.0030.0337.18
4.4.10.0070.0237.18
4.4.00.0100.0477.18
4.3.110.0000.0337.18
4.3.100.0030.0237.18
4.3.90.0000.0307.18
4.3.80.0000.0337.18
4.3.70.0070.0137.18
4.3.60.0000.0337.18
4.3.50.0000.0337.18
4.3.40.0000.0337.18
4.3.30.0000.0377.18
4.3.20.0070.0237.18
4.3.10.0070.0277.18
4.3.00.0070.0337.18

preferences:
38.16 ms | 401 KiB | 5 Q