3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calcDays($startdate, $enddate) { $first = $startdate < $enddate ? $startdate : $enddate; $second = $startdate < $enddate ? $enddate : $startdate; $inbetween = $second - $first; $i[0] = 60; $i[1] = 24; $i[2] = 7; $i[3] = date('t', strtotime('-1 month', $second)); $i[4] = date('L', strtotime('-1 year', $second)) ? 366 : 365; $i[5] = array(31, (date('L', strtotime('-1 year', $second)) ? 28 : 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //$years = floor($inbetween / $i[0] / $i[0] / $i[1] % $i[4]) >= $i[4] ? 1 : 0; //echo $years; $months = 0; $days = 0; $temp = floor($inbetween / $i[0] / $i[0] / $i[1]); $tempMonth = date('n', strtotime('-1 year', $second)) - 1; for($n = 0; $n < 12; $n++) { if($temp >= $i[5][$tempMonth]) { $months += 1; $temp -= $i[5][$tempMonth]; } else { $days = $temp; break; } $tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0; } $years = $months / 12; $months = $months % 12; $hours = floor($inbetween / $i[0] / $i[0] % $i[1]); $minutes = floor($inbetween / $i[0] % $i[0]); $seconds = $inbetween % $i[0]; return $years . " years " . $months . " months " . $days . " days " . $hours . " hours " . $minutes . " minutes " . $seconds . " seconds";; } echo calcDays(1388389157, 1420097957);

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.40.0110.00718.82
8.3.30.0000.01320.34
8.3.20.0070.00020.30
8.3.10.0040.00422.04
8.3.00.0040.00422.45
8.2.170.0140.00322.96
8.2.160.0040.01122.20
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0060.00326.16
8.2.120.0040.00420.94
8.2.110.0100.00022.38
8.2.100.0090.00318.09
8.2.90.0000.00819.30
8.2.80.0030.00619.21
8.2.70.0030.00618.00
8.2.60.0040.00418.04
8.2.50.0000.00818.07
8.2.40.0000.00818.15
8.2.30.0040.00419.54
8.2.20.0000.00718.08
8.2.10.0060.00318.11
8.2.00.0080.00018.16
8.1.270.0080.00023.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00320.84
8.1.230.0060.00618.02
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0040.00417.50
8.1.190.0000.00817.76
8.1.180.0080.00018.10
8.1.170.0040.00418.77
8.1.160.0070.00019.01
8.1.150.0020.00518.84
8.1.140.0000.00717.73
8.1.130.0000.00718.00
8.1.120.0000.00717.75
8.1.110.0020.00517.73
8.1.100.0000.00717.79
8.1.90.0030.00517.63
8.1.80.0000.00717.65
8.1.70.0080.00017.62
8.1.60.0040.00417.69
8.1.50.0040.00417.64
8.1.40.0000.00817.79
8.1.30.0040.00417.88
8.1.20.0030.00517.81
8.1.10.0080.00017.80
8.1.00.0040.00417.87
8.0.300.0000.00918.77
8.0.290.0000.00817.28
8.0.280.0000.00718.60
8.0.270.0040.00417.33
8.0.260.0070.00017.16
8.0.250.0030.00317.37
8.0.240.0040.00417.24
8.0.230.0080.00017.29
8.0.220.0070.00017.20
8.0.210.0030.00317.23
8.0.200.0000.00617.19
8.0.190.0040.00417.25
8.0.180.0080.00017.25
8.0.170.0080.00017.16
8.0.160.0040.00417.10
8.0.150.0050.00217.25
8.0.140.0050.00217.21
8.0.130.0030.00313.61
8.0.120.0040.00417.28
8.0.110.0040.00417.09
8.0.100.0080.00017.29
8.0.90.0040.00417.12
8.0.80.0060.00917.23
8.0.70.0080.00017.10
8.0.60.0080.00017.29
8.0.50.0000.00717.30
8.0.30.0140.01017.37
8.0.20.0130.01017.47
8.0.10.0000.00717.18
8.0.00.0080.01017.15
7.4.330.0000.00516.84
7.4.320.0000.00716.65
7.4.300.0000.00616.82
7.4.290.0070.00016.84
7.4.280.0000.00716.71
7.4.270.0030.00416.66
7.4.260.0060.00013.40
7.4.250.0000.00816.80
7.4.240.0050.00216.74
7.4.230.0070.00016.64
7.4.220.0060.01916.73
7.4.210.0030.01216.79
7.4.200.0040.00316.63
7.4.190.0000.00716.91
7.4.160.0150.00616.60
7.4.150.0120.00917.40
7.4.140.0110.01117.86
7.4.130.0080.01216.79
7.4.120.0090.01016.82
7.4.110.0080.00816.82
7.4.100.0170.00416.77
7.4.90.0030.01516.66
7.4.80.0060.01219.39
7.4.70.0030.01316.62
7.4.60.0090.01216.70
7.4.50.0080.00016.51
7.4.40.0060.01222.77
7.4.30.0090.00616.91
7.4.10.0030.01014.98
7.4.00.0070.00915.32
7.3.330.0000.00513.54
7.3.320.0050.00013.58
7.3.310.0000.00816.61
7.3.300.0000.00816.44
7.3.290.0090.01216.54
7.3.280.0050.01116.60
7.3.270.0110.00517.40
7.3.260.0220.00318.24
7.3.250.0080.01016.74
7.3.240.0090.00916.90
7.3.230.0070.01116.76
7.3.210.0080.00816.81
7.3.200.0090.00919.39
7.3.190.0120.00616.68
7.3.180.0040.01116.87
7.3.170.0100.00616.86
7.3.160.0030.01216.72
7.3.130.0030.01615.36
7.3.120.0080.00715.31
7.3.110.0100.00715.36
7.3.100.0060.00615.19
7.3.90.0060.00915.04
7.3.80.0040.00814.99
7.3.70.0080.00514.86
7.3.60.0100.00014.89
7.3.50.0120.00614.91
7.3.40.0150.00015.21
7.3.30.0060.00615.20
7.3.20.0030.01416.72
7.3.10.0070.00716.79
7.3.00.0060.00617.12
7.2.330.0140.00616.84
7.2.320.0100.01316.70
7.2.310.0040.01316.90
7.2.300.0090.01417.06
7.2.290.0030.01417.13
7.2.260.0110.00715.51
7.2.250.0110.00715.19
7.2.240.0070.01015.32
7.2.230.0030.00915.44
7.2.220.0150.00015.52
7.2.210.0040.01115.20
7.2.200.0060.00915.36
7.2.190.0000.01615.31
7.2.180.0140.00015.44
7.2.170.0100.00315.33
7.2.160.0060.01215.23
7.2.150.0100.00717.04
7.2.140.0060.00917.22
7.2.130.0030.01017.06
7.2.120.0090.00916.92
7.2.110.0030.01517.30
7.2.100.0040.00417.31
7.2.90.0000.01217.22
7.2.80.0000.01617.11
7.2.70.0070.00717.10
7.2.60.0070.00716.88
7.2.50.0030.00617.31
7.2.40.0040.01116.89
7.2.30.0040.00817.29
7.2.20.0000.01117.21
7.2.10.0140.00617.33
7.2.00.0090.00518.21
7.1.330.0130.00316.14
7.1.320.0030.01216.05
7.1.310.0030.00916.09
7.1.300.0070.01016.18
7.1.290.0060.01016.11
7.1.280.0060.00616.08
7.1.270.0120.00616.08
7.1.260.0070.00716.18
7.1.250.0040.00715.88
7.1.240.0080.00816.23
7.1.230.0000.00816.07
7.1.220.0090.00616.05
7.1.210.0060.00916.05
7.1.200.0080.00515.81
7.1.190.0030.01016.05
7.1.180.0030.00716.14
7.1.170.0030.01016.08
7.1.160.0070.00715.80
7.1.150.0070.00715.96
7.1.140.0090.00316.20
7.1.130.0000.01615.89
7.1.120.0070.00715.97
7.1.110.0030.01016.27
7.1.100.0050.00617.19
7.1.90.0080.00016.22
7.1.80.0040.00416.11
7.1.70.0050.00516.77
7.1.60.0020.01216.83
7.1.50.0400.00515.65
7.1.40.0040.01116.09
7.1.30.0030.00715.79
7.1.20.0040.00816.10
7.1.10.0060.00915.88
7.1.00.0050.02019.28
7.0.330.0080.00815.60
7.0.320.0040.01115.41
7.0.310.0030.00715.73
7.0.300.0090.00615.71
7.0.290.0030.00915.58
7.0.280.0070.00715.44
7.0.270.0100.00715.63
7.0.260.0000.01015.32
7.0.250.0000.00915.68
7.0.240.0080.00315.67
7.0.230.0000.01715.63
7.0.220.0060.00615.38
7.0.210.0030.01015.58
7.0.200.0030.01216.36
7.0.190.0070.00315.38
7.0.180.0030.01015.68
7.0.170.0140.00015.72
7.0.160.0060.00615.51
7.0.150.0110.00415.77
7.0.140.0060.03818.88
7.0.130.0000.00915.71
7.0.120.0030.01015.58
7.0.110.0070.00315.71
7.0.100.0040.01115.56
7.0.90.0000.01515.49
7.0.80.0280.04417.60
7.0.70.0340.04017.76
7.0.60.0290.02817.83
7.0.50.0350.04618.00
7.0.40.0050.02716.90
7.0.30.0050.04416.83
7.0.20.0100.02216.88
7.0.10.0070.03516.94
7.0.00.0050.03616.88
5.6.400.0000.01314.45
5.6.390.0000.01514.93
5.6.380.0120.00314.74
5.6.370.0030.00914.44
5.6.360.0040.01414.91
5.6.350.0030.00914.60
5.6.340.0140.00014.80
5.6.330.0070.01014.55
5.6.320.0060.00914.56
5.6.310.0080.00414.56
5.6.300.0090.00614.24
5.6.290.0040.00714.59
5.6.280.0070.03717.92
5.6.270.0090.00614.90
5.6.260.0130.00014.45
5.6.250.0040.00414.57
5.6.240.0090.00914.47
5.6.230.0090.03217.80
5.6.220.0070.02217.61
5.6.210.0020.04317.74
5.6.200.0070.04717.74
5.6.190.0050.02517.75
5.6.180.0100.04017.73
5.6.170.0050.03317.75
5.6.160.0050.04018.03
5.6.150.0000.03417.89
5.6.140.0100.04517.92
5.6.130.0060.04617.89
5.6.120.0100.03917.78
5.6.110.0120.02817.84
5.6.100.0050.04117.82
5.6.90.0050.02917.80
5.6.80.0080.02617.51
5.6.70.0110.02817.46
5.6.60.0100.04217.47
5.6.50.0080.03017.66
5.6.40.0090.04317.54
5.6.30.0030.04817.26
5.6.20.0070.03517.41
5.6.10.0050.04017.44
5.6.00.0080.02317.47
5.5.380.0090.00914.43
5.5.370.0140.03617.67
5.5.360.0100.04217.54
5.5.350.0050.05117.54
5.5.340.0060.04117.70
5.5.330.0090.03017.66
5.5.320.0070.02817.78
5.5.310.0080.02817.81
5.5.300.0030.04517.61
5.5.290.0070.03817.77
5.5.280.0080.03517.80
5.5.270.0070.02617.64
5.5.260.0080.02817.61
5.5.250.0110.02717.72
5.5.240.0130.03117.42
5.5.230.0090.03417.20
5.5.220.0120.03717.42
5.5.210.0030.04817.50
5.5.200.0060.04317.28
5.5.190.0100.03017.52
5.5.180.0050.04817.38
5.5.170.0070.00714.55
5.5.160.0020.02717.24
5.5.150.0070.04217.51
5.5.140.0060.04317.39
5.5.130.0060.04117.43
5.5.120.0080.04317.40
5.5.110.0080.03217.46
5.5.100.0020.04317.26
5.5.90.0050.03817.44
5.5.80.0030.04317.13
5.5.70.0030.02817.40
5.5.60.0050.04217.45
5.5.50.0030.03817.36
5.5.40.0060.03117.25
5.5.30.0120.03517.05
5.5.20.0080.04117.45
5.5.10.0080.03717.21
5.5.00.0050.02917.28
5.4.450.0060.04515.29
5.4.440.0060.02215.46
5.4.430.0070.02515.42
5.4.420.0080.03215.46
5.4.410.0070.02715.39
5.4.400.0050.04015.15
5.4.390.0100.03715.20
5.4.380.0090.04015.16
5.4.370.0050.04115.25
5.4.360.0080.04115.14
5.4.350.0020.04715.28
5.4.340.0090.03715.31
5.4.330.0060.00611.29
5.4.320.0030.04615.29
5.4.310.0020.03015.26
5.4.300.0050.04215.27
5.4.290.0050.02415.17
5.4.280.0120.03815.22
5.4.270.0080.04015.32
5.4.260.0060.02415.08
5.4.250.0050.04215.07
5.4.240.0050.04015.34
5.4.230.0000.03215.13
5.4.220.0080.02715.28
5.4.210.0100.04015.21
5.4.200.0150.03015.31
5.4.190.0020.03315.07
5.4.180.0110.02615.11
5.4.170.0080.03015.27
5.4.160.0150.03015.24
5.4.150.0080.02815.27
5.4.140.0010.03313.80
5.4.130.0100.03213.82
5.4.120.0030.03013.89
5.4.110.0020.02814.00
5.4.100.0050.03713.98
5.4.90.0050.04014.00
5.4.80.0100.03713.82
5.4.70.0050.03014.06
5.4.60.0050.04013.88
5.4.50.0040.02913.92
5.4.40.0080.03313.75
5.4.30.0080.03813.85
5.4.20.0020.03413.82
5.4.10.0020.03313.88
5.4.00.0070.03313.64
5.3.290.0080.02712.83
5.3.280.0070.04012.72
5.3.270.0050.03012.77
5.3.260.0040.02412.81
5.3.250.0070.03812.81
5.3.240.0060.03612.67
5.3.230.0040.02712.83
5.3.220.0080.03912.71
5.3.210.0050.02912.56
5.3.200.0050.03812.59
5.3.190.0080.04012.72
5.3.180.0030.04712.64
5.3.170.0050.03712.78
5.3.160.0030.03912.59
5.3.150.0000.04312.73
5.3.140.0130.03312.63
5.3.130.0070.03812.70
5.3.120.0040.04112.64
5.3.110.0040.04112.81
5.3.100.0050.03812.37
5.3.90.0050.04112.39
5.3.80.0030.03912.49
5.3.70.0070.03912.44
5.3.60.0020.02512.36
5.3.50.0050.04112.47
5.3.40.0030.03712.45
5.3.30.0050.02312.36
5.3.20.0000.03412.23
5.3.10.0100.03212.10
5.3.00.0010.03012.13
5.2.170.0070.06311.08
5.2.160.0030.06011.22
5.2.150.0070.06011.10
5.2.140.0030.06311.22
5.2.130.0100.06011.21
5.2.120.0130.05011.01
5.2.110.0070.05311.00
5.2.100.0070.04711.05
5.2.90.0070.05711.11
5.2.80.0000.06311.18
5.2.70.0100.04311.00
5.2.60.0100.06011.16
5.2.50.0070.05011.16
5.2.40.0000.06711.01
5.2.30.0030.05711.10
5.2.20.0030.06311.10
5.2.10.0030.05710.91
5.2.00.0030.04710.60
5.1.60.0030.05310.14
5.1.50.0070.0509.90
5.1.40.0000.05010.03
5.1.30.0030.05710.29
5.1.20.0070.05010.46
5.1.10.0070.05710.19
5.1.00.0100.04710.15
5.0.50.0000.0508.57
5.0.40.0070.0178.45
5.0.30.0030.0608.30
5.0.20.0000.0438.21
5.0.10.0070.0378.28
5.0.00.0070.0578.28
4.4.90.0030.0177.39
4.4.80.0000.0337.39
4.4.70.0030.0377.39
4.4.60.0000.0277.39
4.4.50.0030.0337.39
4.4.40.0000.0577.39
4.4.30.0030.0307.39
4.4.20.0030.0377.39
4.4.10.0130.0107.39
4.4.00.0030.0437.39
4.3.110.0030.0277.39
4.3.100.0000.0307.39
4.3.90.0000.0307.39
4.3.80.0000.0577.39
4.3.70.0030.0307.39
4.3.60.0000.0337.39
4.3.50.0100.0237.39
4.3.40.0000.0477.39
4.3.30.0000.0377.39
4.3.20.0030.0337.39
4.3.10.0030.0337.39
4.3.00.0000.0377.39

preferences:
46.21 ms | 400 KiB | 5 Q