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; } $hours = floor($inbetween / $i[0] / $i[0] % $i[1]); $minutes = floor($inbetween / $i[0] % $i[0]); $seconds = $inbetween % $i[0]; return $months . " months " . $days . " days " . $hours . " hours " . $minutes . " minutes " . $seconds . " seconds";; } echo calcDays(1388389157, 1420097956);

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.0130.00617.13
8.3.50.0120.00817.62
8.3.40.0040.01219.26
8.3.30.0160.00619.05
8.3.20.0030.00619.11
8.3.10.0080.00019.13
8.3.00.0080.00019.75
8.2.180.0170.00717.00
8.2.170.0090.00622.96
8.2.160.0040.01121.30
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0080.00020.08
8.2.110.0060.00321.22
8.2.100.0090.00318.09
8.2.90.0030.00619.72
8.2.80.0040.00419.38
8.2.70.0040.00418.00
8.2.60.0050.00518.18
8.2.50.0080.00018.07
8.2.40.0000.00818.41
8.2.30.0050.00318.34
8.2.20.0030.00618.24
8.2.10.0040.00418.04
8.2.00.0050.00218.21
8.1.280.0070.01125.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0050.00228.09
8.1.240.0030.00622.82
8.1.230.0040.00820.97
8.1.220.0030.00717.91
8.1.210.0050.00319.16
8.1.200.0000.00917.61
8.1.190.0030.00617.64
8.1.180.0080.00018.10
8.1.170.0000.00818.87
8.1.160.0040.00419.04
8.1.150.0000.00819.00
8.1.140.0030.00617.81
8.1.130.0050.00217.96
8.1.120.0040.00417.83
8.1.110.0040.00417.82
8.1.100.0070.00017.84
8.1.90.0050.00317.82
8.1.80.0070.00017.84
8.1.70.0020.00517.77
8.1.60.0000.00817.86
8.1.50.0060.00317.65
8.1.40.0080.00017.82
8.1.30.0040.00417.92
8.1.20.0040.00417.86
8.1.10.0000.00717.87
8.1.00.0040.00417.75
8.0.300.0070.00020.11
8.0.290.0000.00817.13
8.0.280.0070.00018.69
8.0.270.0070.00017.52
8.0.260.0080.00017.14
8.0.250.0040.00417.40
8.0.240.0040.00417.36
8.0.230.0000.00817.39
8.0.220.0020.00517.30
8.0.210.0040.00417.22
8.0.200.0070.00017.25
8.0.190.0050.00217.25
8.0.180.0040.00417.36
8.0.170.0030.00617.20
8.0.160.0040.00417.27
8.0.150.0040.00417.27
8.0.140.0040.00417.26
8.0.130.0060.00013.63
8.0.120.0070.00017.16
8.0.110.0040.00417.33
8.0.100.0040.00417.13
8.0.90.0030.00517.21
8.0.80.0090.00617.26
8.0.70.0040.00417.22
8.0.60.0040.00417.20
8.0.50.0000.00717.34
8.0.30.0110.00717.36
8.0.20.0080.01117.37
8.0.10.0000.00817.45
8.0.00.0070.01317.22
7.4.330.0000.00513.27
7.4.320.0070.00016.83
7.4.300.0000.00816.88
7.4.290.0000.00716.71
7.4.280.0000.00816.81
7.4.270.0030.00316.70
7.4.260.0030.00313.52
7.4.250.0040.00416.75
7.4.240.0030.00516.84
7.4.230.0000.00716.70
7.4.220.0120.00616.94
7.4.210.0070.01016.84
7.4.200.0070.00016.69
7.4.190.0000.00716.96
7.4.160.0060.01516.83
7.4.150.0080.01616.86
7.4.140.0100.01016.71
7.4.130.0130.00516.76
7.4.120.0030.01316.80
7.4.110.0090.01116.89
7.4.100.0100.01316.85
7.4.90.0180.00016.91
7.4.80.0060.01619.39
7.4.70.0060.01016.97
7.4.60.0060.01116.79
7.4.50.0030.00616.84
7.4.40.0110.00016.73
7.4.30.0120.00617.00
7.4.10.0080.01615.01
7.4.00.0080.01015.25
7.3.330.0060.00013.44
7.3.320.0050.00013.50
7.3.310.0030.00316.74
7.3.300.0050.00316.66
7.3.290.0060.00916.55
7.3.280.0060.01216.61
7.3.270.0100.00616.72
7.3.260.0110.00816.73
7.3.250.0070.01216.79
7.3.240.0140.00416.79
7.3.230.0140.00316.78
7.3.210.0180.00016.59
7.3.200.0080.00816.91
7.3.190.0070.01116.75
7.3.180.0100.01016.70
7.3.170.0090.00616.74
7.3.160.0120.00916.99
7.3.130.0090.01315.05
7.3.120.0080.01115.03
7.3.110.0130.00715.02
7.3.100.0050.01415.29
7.3.90.0110.00414.90
7.3.80.0070.01115.39
7.3.70.0070.01115.24
7.3.60.0070.01015.09
7.3.50.0130.00615.12
7.3.40.0090.00915.11
7.3.30.0080.00815.17
7.3.20.0100.01317.07
7.3.10.0070.00917.02
7.3.00.0060.01316.90
7.2.330.0120.00617.07
7.2.320.0180.00017.07
7.2.310.0140.00417.25
7.2.300.0090.01017.14
7.2.290.0080.00917.18
7.2.260.0100.01015.07
7.2.250.0110.01115.23
7.2.240.0110.00715.54
7.2.230.0100.01015.43
7.2.220.0080.01215.36
7.2.210.0080.01115.07
7.2.200.0150.00715.13
7.2.190.0120.00615.46
7.2.180.0080.01315.37
7.2.170.0080.01115.37
7.2.160.0040.01515.44
7.2.150.0040.01517.35
7.2.140.0150.00617.27
7.2.130.0100.00817.11
7.2.120.0090.01117.18
7.2.110.0100.00817.22
7.2.100.0060.01117.14
7.2.90.0110.00917.19
7.2.80.0140.00517.21
7.2.70.0100.00717.05
7.2.60.0080.01217.11
7.2.50.0110.00817.21
7.2.40.0070.01117.27
7.2.30.0140.00517.27
7.2.20.0130.00517.14
7.2.10.0050.01517.15
7.2.00.0060.00818.03
7.1.330.0130.00816.21
7.1.320.0040.01416.04
7.1.310.0100.00716.09
7.1.300.0100.00416.05
7.1.290.0000.01816.17
7.1.280.0080.01115.68
7.1.270.0060.00916.07
7.1.260.0110.00716.12
7.1.250.0060.01015.94
7.1.240.0060.00915.75
7.1.230.0070.01116.20
7.1.220.0100.01016.14
7.1.210.0080.00915.79
7.1.200.0090.00916.16
7.1.190.0130.00916.03
7.1.180.0100.00616.05
7.1.170.0060.01215.93
7.1.160.0070.01116.07
7.1.150.0090.00915.96
7.1.140.0070.01016.13
7.1.130.0120.00716.03
7.1.120.0040.01515.82
7.1.110.0100.00716.22
7.1.100.0200.00817.12
7.1.90.0090.00915.91
7.1.80.0030.01516.13
7.1.70.0100.00916.86
7.1.60.0090.01017.63
7.1.50.0070.01016.54
7.1.40.0060.00915.90
7.1.30.0000.01116.05
7.1.20.0060.00615.96
7.1.10.0030.01016.05
7.1.00.0000.04719.07
7.0.330.0120.00315.73
7.0.320.0090.00915.48
7.0.310.0110.00715.24
7.0.300.0140.00715.48
7.0.290.0100.01015.54
7.0.280.0080.00815.37
7.0.270.0090.00515.70
7.0.260.0090.00915.52
7.0.250.0100.01015.74
7.0.240.0000.01815.66
7.0.230.0000.01415.45
7.0.220.0070.01015.63
7.0.210.0110.00515.77
7.0.200.0050.00715.97
7.0.190.0070.00715.59
7.0.180.0060.00915.43
7.0.170.0170.00015.69
7.0.160.0060.01315.44
7.0.150.0030.00915.46
7.0.140.0030.04218.82
7.0.130.0030.01215.49
7.0.120.0050.03318.86
7.0.110.0080.02117.86
7.0.100.0030.02717.70
7.0.90.0180.02817.66
7.0.80.0120.02117.74
7.0.70.0080.02517.75
7.0.60.0030.02817.80
7.0.50.0120.02217.79
7.0.40.0030.02116.74
7.0.30.0020.02216.70
7.0.20.0030.02416.71
7.0.10.0070.02316.76
7.0.00.0050.02016.71
5.6.400.0130.00314.46
5.6.390.0040.01514.68
5.6.380.0110.00314.57
5.6.370.0000.01314.58
5.6.360.0100.01014.52
5.6.350.0040.01614.78
5.6.340.0070.01114.46
5.6.330.0030.01614.69
5.6.320.0060.00914.57
5.6.310.0080.00814.72
5.6.300.0030.01414.38
5.6.290.0100.00014.58
5.6.280.0100.04017.80
5.6.270.0040.01114.50
5.6.260.0050.03217.56
5.6.250.0090.03417.75
5.6.240.0040.02817.63
5.6.230.0050.02617.65
5.6.220.0070.03417.63
5.6.210.0080.02517.55
5.6.200.0080.02317.52
5.6.190.0060.03017.61
5.6.180.0050.02117.55
5.6.170.0070.01717.53
5.6.160.0060.02317.58
5.6.150.0030.02417.66
5.6.140.0050.02217.63
5.6.130.0090.03217.66
5.6.120.0050.04517.65
5.6.110.0050.04017.61
5.6.100.0000.04317.61
5.6.90.0060.02217.54
5.6.80.0060.03817.19
5.6.70.0050.02317.36
5.6.60.0090.04117.22
5.6.50.0060.03317.36
5.6.40.0100.02317.33
5.6.30.0090.01817.11
5.6.20.0070.02017.33
5.6.10.0110.01817.30
5.6.00.0050.03717.23
5.5.380.0030.02716.06
5.5.370.0090.01916.08
5.5.360.0080.02816.21
5.5.350.0060.02316.03
5.5.340.0050.02516.59
5.5.330.0100.01916.17
5.5.320.0070.02216.06
5.5.310.0040.02216.33
5.5.300.0080.01816.28
5.5.290.0110.03816.27
5.5.280.0050.04216.32
5.5.270.0080.02716.48
5.5.260.0060.04416.29
5.5.250.0100.03816.12
5.5.240.0030.04415.96
5.5.230.0060.02216.00
5.5.220.0050.02215.77
5.5.210.0050.03216.10
5.5.200.0070.02215.91
5.5.190.0040.02516.05
5.5.180.0080.04316.04
5.5.170.0040.01114.21
5.5.160.0050.02516.03
5.5.150.0100.04015.94
5.5.140.0030.02315.79
5.5.130.0050.02715.75
5.5.120.0080.03815.96
5.5.110.0060.02715.82
5.5.100.0050.02315.89
5.5.90.0020.03715.96
5.5.80.0040.04115.87
5.5.70.0080.03816.07
5.5.60.0110.03615.76
5.5.50.0070.03815.97
5.5.40.0090.02015.85
5.5.30.0100.03215.92
5.5.20.0080.03915.97
5.5.10.0080.03016.00
5.5.00.0020.04115.85
5.4.450.0060.01915.34
5.4.440.0050.04015.34
5.4.430.0060.03215.38
5.4.420.0030.04315.42
5.4.410.0050.04815.34
5.4.400.0090.02015.13
5.4.390.0090.02315.09
5.4.380.0030.02315.38
5.4.370.0070.02515.26
5.4.360.0030.02415.33
5.4.350.0070.04114.98
5.4.340.0070.03415.18
5.4.330.0070.00511.33
5.4.320.0030.02315.34
5.4.310.0050.03715.21
5.4.300.0070.03815.13
5.4.290.0030.03815.18
5.4.280.0060.03514.99
5.4.270.0070.03415.23
5.4.260.0040.03615.15
5.4.250.0060.02315.11
5.4.240.0020.02815.06
5.4.230.0080.02015.08
5.4.220.0050.04415.15
5.4.210.0070.03715.23
5.4.200.0070.03715.38
5.4.190.0090.02215.29
5.4.180.0030.03815.35
5.4.170.0060.02015.25
5.4.160.0050.04115.30
5.4.150.0100.03815.10
5.4.140.0030.04314.10
5.4.130.0050.03213.85
5.4.120.0030.03513.92
5.4.110.0030.03913.77
5.4.100.0060.03713.96
5.4.90.0040.03713.86
5.4.80.0070.03913.77
5.4.70.0030.02013.90
5.4.60.0050.03213.81
5.4.50.0090.02613.75
5.4.40.0020.03813.95
5.4.30.0080.03613.94
5.4.20.0080.03213.98
5.4.10.0050.05313.92
5.4.00.0060.02713.62
5.3.290.0050.02012.86
5.3.280.0010.04112.79
5.3.270.0030.02812.87
5.3.260.0040.03412.83
5.3.250.0070.03712.85
5.3.240.0040.03912.78
5.3.230.0030.03312.71
5.3.220.0050.03412.77
5.3.210.0030.02112.75
5.3.200.0020.02812.78
5.3.190.0030.03612.79
5.3.180.0030.04012.77
5.3.170.0080.03712.84
5.3.160.0020.02212.78
5.3.150.0030.04112.79
5.3.140.0070.03712.76
5.3.130.0020.02012.76
5.3.120.0060.03812.81
5.3.110.0040.04212.77
5.3.100.0050.02012.50
5.3.90.0030.02512.54
5.3.80.0080.03212.50
5.3.70.0050.04012.47
5.3.60.0080.03712.48
5.3.50.0030.02812.46
5.3.40.0020.02812.52
5.3.30.0010.03412.50
5.3.20.0000.02212.27
5.3.10.0050.01612.38
5.3.00.0040.01912.30
5.2.170.0070.03312.02
5.2.160.0070.05312.02
5.2.150.0030.03312.02
5.2.140.0000.04012.02
5.2.130.0000.03012.02
5.2.120.0130.02312.02
5.2.110.0070.03012.02
5.2.100.0000.03012.02
5.2.90.0000.03012.02
5.2.80.0030.07312.02
5.2.70.0030.03712.02
5.2.60.0030.03012.02
5.2.50.0030.02712.02
5.2.40.0000.02712.02
5.2.30.0000.03012.02
5.2.20.0070.02712.02
5.2.10.0000.02712.02
5.2.00.0030.03312.02
5.1.60.0070.02012.02
5.1.50.0030.03312.02
5.1.40.0000.02312.02
5.1.30.0030.03712.02
5.1.20.0030.02312.02
5.1.10.0030.03312.02
5.1.00.0000.02712.02
5.0.50.0000.02312.02
5.0.40.0070.01312.02
5.0.30.0000.02712.02
5.0.20.0000.02012.02
5.0.10.0070.02012.02
5.0.00.0070.04012.02
4.4.90.0000.02712.02
4.4.80.0000.01712.02
4.4.70.0000.01712.02
4.4.60.0000.01712.02
4.4.50.0000.01712.02
4.4.40.0000.02312.02
4.4.30.0030.01712.02
4.4.20.0000.01312.02
4.4.10.0030.02312.02
4.4.00.0030.02312.02
4.3.110.0000.01312.02
4.3.100.0030.02712.02
4.3.90.0030.03312.02
4.3.80.0000.02312.02
4.3.70.0030.01012.02
4.3.60.0100.00712.02
4.3.50.0030.01312.02
4.3.40.0000.05312.02
4.3.30.0000.01312.02
4.3.20.0000.04012.02
4.3.10.0000.01712.02
4.3.00.0030.01712.02

preferences:
59.04 ms | 401 KiB | 5 Q