3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dateDiff($startdate, $enddate) { $first = $startdate < $enddate ? $startdate : $enddate; $second = $startdate < $enddate ? $enddate : $startdate; $inbetween = $second - $first; $i[0] = 60; $i[1] = 24; $i[2] = array(31, (date('L', strtotime('-1 year', $second)) ? 28 : 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $months = 0; $days = 0; $tempDays = $inbetween / $i[0] / $i[0] / $i[1] / 365.25; $tempMonth = date('n', strtotime('-1 year', $second)) - 1; for($n = 0; $n < 12; $n++) { if($tempDays >= $i[2][$tempMonth]) { $months += 1; $tempDays -= $i[2][$tempMonth]; } else { $days = round($tempDays); break; } $tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0; } $years = floor(date('Y', $second) - date('Y', $first) + $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]; $dateObj = new stdClass(); $dateObj->years = $years; $dateObj->months = $months; $dateObj->days = $days; $dateObj->hours = $hours; $dateObj->minutes = $minutes; $dateObj->seconds = $seconds; return $dateObj; } $mydate = dateDiff(1388534400, 1454198400); echo $mydate->years;

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.0070.00718.56
8.3.50.0280.00721.26
8.3.40.0110.00418.79
8.3.30.0140.00020.32
8.3.20.0040.00420.46
8.3.10.0040.00422.21
8.3.00.0040.00422.57
8.2.180.0120.00317.00
8.2.170.0140.00722.96
8.2.160.0070.00722.38
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0080.00026.16
8.2.120.0060.00321.00
8.2.110.0030.00720.52
8.2.100.0080.00418.28
8.2.90.0050.00319.32
8.2.80.0000.00819.34
8.2.70.0060.00318.00
8.2.60.0090.00018.05
8.2.50.0040.00418.13
8.2.40.0000.00818.28
8.2.30.0050.00319.61
8.2.20.0060.00318.15
8.2.10.0080.00018.23
8.2.00.0000.00818.23
8.1.280.0120.00325.92
8.1.270.0070.01023.99
8.1.260.0070.00326.35
8.1.250.0040.00428.09
8.1.240.0100.00022.12
8.1.230.0080.00318.08
8.1.220.0030.00517.78
8.1.210.0040.00418.77
8.1.200.0040.00417.63
8.1.190.0000.00817.63
8.1.180.0080.00018.10
8.1.170.0000.00818.90
8.1.160.0000.00819.12
8.1.150.0070.00019.11
8.1.140.0040.00417.84
8.1.130.0030.00317.95
8.1.120.0000.00717.80
8.1.110.0000.00817.85
8.1.100.0030.00617.72
8.1.90.0080.00017.81
8.1.80.0000.00817.79
8.1.70.0040.00417.75
8.1.60.0040.00417.88
8.1.50.0060.00317.82
8.1.40.0040.00417.84
8.1.30.0040.00417.97
8.1.20.0000.00817.81
8.1.10.0040.00417.91
8.1.00.0030.00617.86
8.0.300.0000.00818.77
8.0.290.0000.00717.55
8.0.280.0000.00718.73
8.0.270.0070.00017.55
8.0.260.0040.00417.18
8.0.250.0030.00317.25
8.0.240.0060.00317.43
8.0.230.0040.00417.40
8.0.220.0000.00717.33
8.0.210.0070.00017.36
8.0.200.0030.00317.38
8.0.190.0000.00817.33
8.0.180.0040.00417.39
8.0.170.0040.00417.38
8.0.160.0040.00417.30
8.0.150.0070.00017.19
8.0.140.0070.00017.27
8.0.130.0000.00713.61
8.0.120.0030.00617.28
8.0.110.0040.00417.25
8.0.100.0040.00417.16
8.0.90.0000.00717.19
8.0.80.0060.01217.28
8.0.70.0040.00417.13
8.0.60.0000.00717.21
8.0.50.0030.00517.28
8.0.30.0080.01117.52
8.0.20.0110.01117.40
8.0.10.0040.00417.48
8.0.00.0120.00817.12
7.4.330.0020.00216.87
7.4.320.0030.00316.87
7.4.300.0030.00316.82
7.4.290.0000.00716.72
7.4.280.0000.00716.91
7.4.270.0030.00316.91
7.4.260.0030.00313.41
7.4.250.0030.00616.87
7.4.240.0040.00416.86
7.4.230.0040.00416.65
7.4.220.0160.00616.91
7.4.210.0060.01016.92
7.4.200.0030.00316.93
7.4.190.0060.00017.00
7.4.160.0000.01816.80
7.4.150.0090.00917.40
7.4.140.0100.00717.86
7.4.130.0120.00616.74
7.4.120.0130.00516.92
7.4.110.0070.01416.91
7.4.100.0150.00316.67
7.4.90.0060.01216.75
7.4.80.0060.01116.82
7.4.70.0100.01116.94
7.4.60.0060.01116.79
7.4.50.0000.00817.09
7.4.40.0070.01022.77
7.4.30.0110.00816.73
7.4.00.0030.01015.46
7.3.330.0050.00013.66
7.3.320.0050.00013.38
7.3.310.0030.00316.52
7.3.300.0000.00716.70
7.3.290.0000.01416.65
7.3.280.0130.00816.69
7.3.270.0110.00617.40
7.3.260.0100.00718.24
7.3.250.0150.00216.71
7.3.240.0090.00616.89
7.3.230.0100.01416.93
7.3.210.0140.00416.89
7.3.200.0030.01319.39
7.3.190.0120.00616.68
7.3.180.0100.00716.91
7.3.170.0120.00316.97
7.3.160.0080.00916.59
7.3.120.0030.01315.23
7.3.00.0120.00416.77
7.2.330.0060.01317.16
7.2.320.0140.01016.93
7.2.310.0070.01017.07
7.2.300.0070.01016.75
7.2.290.0060.01116.80
7.2.130.0170.00017.02
7.2.120.0110.00716.86
7.2.110.0110.00717.10
7.2.100.0090.00917.16
7.2.90.0110.00617.02
7.2.80.0070.01017.32
7.2.70.0150.00617.13
7.2.60.0140.00016.55
7.2.50.0100.00717.20
7.2.40.0110.00716.84
7.2.30.0070.01017.16
7.2.20.0070.01016.96
7.2.10.0060.01317.20
7.2.00.0110.01117.15
7.1.250.0100.00715.93
7.1.240.0060.01215.89
7.1.230.0100.01015.82
7.1.220.0100.00915.99
7.1.210.0090.00915.98
7.1.200.0030.01215.84
7.1.190.0130.00715.89
7.1.180.0090.00615.47
7.1.170.0120.00316.02
7.1.160.0150.00315.77
7.1.150.0160.00015.96
7.1.140.0080.00815.93
7.1.130.0060.00915.98
7.1.120.0120.00615.93
7.1.110.0060.00915.91
7.1.100.0060.00617.10
7.1.90.0120.00815.68
7.1.80.0110.01116.05
7.1.70.0130.00316.71
7.1.60.0080.01517.52
7.1.50.0130.00816.51
7.1.40.0100.00716.10
7.1.30.0150.00716.00
7.1.20.0140.00615.87
7.1.10.0170.00516.05
7.1.00.0060.02519.34
7.0.330.0090.00815.11
7.0.320.0100.00915.57
7.0.310.0070.01115.44
7.0.300.0100.00715.42
7.0.290.0100.00715.62
7.0.280.0090.00915.59
7.0.270.0090.00615.31
7.0.260.0080.00815.26
7.0.250.0040.01215.54
7.0.240.0090.00615.67
7.0.230.0060.00915.39
7.0.220.0130.00315.62
7.0.210.0110.00415.38
7.0.200.0060.00616.21
7.0.190.0170.00315.33
7.0.180.0130.00315.44
7.0.170.0120.00415.30
7.0.160.0030.01315.43
7.0.150.0090.00915.51
7.0.140.0050.04118.72
7.0.130.0100.00715.36
7.0.120.0110.00415.38
7.0.110.0070.00715.45
7.0.100.0140.00315.50
7.0.90.0130.04018.62
7.0.80.0110.04118.52
7.0.70.0160.03818.51
7.0.60.0050.04518.60
7.0.50.0130.02218.93
7.0.40.0090.02716.84
7.0.30.0080.04116.81
7.0.20.0030.05116.75
7.0.10.0080.04516.80
7.0.00.0020.04116.92
5.6.380.0100.00314.61
5.6.370.0040.01114.63
5.6.360.0000.01614.86
5.6.350.0150.00414.70
5.6.340.0090.00914.89
5.6.330.0070.01414.37
5.6.320.0140.00514.57
5.6.310.0080.01214.36
5.6.300.0140.00414.81
5.6.290.0090.00914.76
5.6.280.0130.03517.83
5.6.270.0100.00314.31
5.6.260.0030.01214.59
5.6.250.0090.00414.75
5.6.240.0050.04617.44
5.6.230.0080.03217.59
5.6.220.0070.03617.45
5.6.210.0120.03717.69
5.6.200.0120.03817.90
5.6.190.0120.04217.83
5.6.180.0100.04317.68
5.6.170.0080.04517.54
5.6.160.0110.01817.84
5.6.150.0040.03317.85
5.6.140.0030.03217.81
5.6.130.0030.02817.80
5.6.120.0080.04617.68
5.6.110.0070.02817.84
5.6.100.0090.04517.83
5.6.90.0050.04817.71
5.6.80.0070.03717.41
5.6.70.0030.02817.34
5.6.60.0070.03017.33
5.6.50.0070.02717.31
5.6.40.0090.03717.34
5.6.30.0050.04717.41
5.6.20.0040.03917.55
5.6.10.0080.03817.52
5.6.00.0050.03317.30
5.5.380.0030.04515.98
5.5.370.0030.03715.87
5.5.360.0030.03615.96
5.5.350.0140.02016.01
5.5.340.0030.04316.22
5.5.330.0040.04316.19
5.5.320.0060.04416.14
5.5.310.0050.03116.08
5.5.300.0060.04316.03
5.5.290.0080.04216.14
5.5.280.0030.04216.16
5.5.270.0080.04416.15
5.5.260.0090.04016.08
5.5.250.0070.04016.13
5.5.240.0030.03815.85
5.5.230.0060.03315.74
5.5.220.0030.04216.00
5.5.210.0040.04115.91
5.5.200.0080.03815.59
5.5.190.0090.03515.82
5.5.180.0050.04015.84
5.5.170.0030.00611.20
5.5.160.0090.03715.70
5.5.150.0050.04315.73
5.5.140.0060.03415.87
5.5.130.0080.03715.69
5.5.120.0050.03215.55
5.5.110.0090.02915.62
5.5.100.0060.03815.77
5.5.90.0070.03815.66
5.5.80.0050.03215.77
5.5.70.0080.04015.66
5.5.60.0030.03915.70
5.5.50.0030.03815.73
5.5.40.0060.04115.68
5.5.30.0060.02615.68
5.5.20.0060.03415.53
5.5.10.0030.03215.77
5.5.00.0100.03515.79
5.4.450.0000.03315.51
5.4.440.0050.02615.30
5.4.430.0090.03715.39
5.4.420.0130.03715.43
5.4.410.0110.04215.25
5.4.400.0090.04015.28
5.4.390.0050.04215.15
5.4.380.0050.04015.25
5.4.370.0030.04415.33
5.4.360.0030.03715.35
5.4.350.0000.04215.28
5.4.340.0070.04015.04
5.4.330.0000.01111.05
5.4.320.0090.03815.12
5.4.310.0040.04115.17
5.4.300.0100.03615.17
5.4.290.0020.03915.17
5.4.280.0070.03315.27
5.4.270.0030.03615.09
5.4.260.0100.03515.22
5.4.250.0050.02515.22
5.4.240.0100.03315.17
5.4.230.0080.03715.14
5.4.220.0050.03714.99
5.4.210.0020.04415.11
5.4.200.0070.03215.10
5.4.190.0070.03215.23
5.4.180.0030.03515.26
5.4.170.0040.03715.11
5.4.160.0080.03315.09
5.4.150.0060.03715.15
5.4.140.0020.03713.80
5.4.130.0070.03413.95
5.4.120.0080.03413.97
5.4.110.0080.02413.95
5.4.100.0070.02513.77
5.4.90.0000.04413.80
5.4.80.0100.02513.97
5.4.70.0060.02313.88
5.4.60.0040.03613.91
5.4.50.0030.04213.87
5.4.40.0030.04013.98
5.4.30.0050.03813.99
5.4.20.0070.04013.80
5.4.10.0040.04013.98
5.4.00.0000.04313.77
5.3.290.0030.04012.85
5.3.280.0080.03712.78
5.3.270.0040.04012.83
5.3.260.0100.02012.82
5.3.250.0020.04212.82
5.3.240.0030.03012.83
5.3.230.0040.03612.80
5.3.220.0030.04312.73
5.3.210.0050.03912.80
5.3.200.0030.03512.74
5.3.190.0060.03612.73
5.3.180.0100.03412.73
5.3.170.0020.04412.87
5.3.160.0050.04112.79
5.3.150.0100.03012.83
5.3.140.0050.04312.84
5.3.130.0050.04512.80
5.3.120.0030.03712.79
5.3.110.0060.03812.74
5.3.100.0030.04012.57
5.3.90.0060.03712.55
5.3.80.0120.03012.46
5.3.70.0040.03912.44
5.3.60.0020.02212.47
5.3.50.0090.03212.49
5.3.40.0050.04112.43
5.3.30.0030.04112.43
5.3.20.0070.03612.25
5.3.10.0030.03812.33
5.3.00.0040.04112.24
5.2.170.0060.02611.06
5.2.160.0060.03211.15
5.2.150.0030.03511.16
5.2.140.0080.02811.11
5.2.130.0040.02911.12
5.2.120.0030.02811.13
5.2.110.0060.03111.01
5.2.100.0030.02011.13
5.2.90.0070.03011.14
5.2.80.0010.03211.01
5.2.70.0040.03511.10
5.2.60.0060.03111.10
5.2.50.0050.03211.04
5.2.40.0050.03111.12
5.2.30.0020.02511.07
5.2.20.0000.03411.07
5.2.10.0020.03211.00
5.2.00.0060.02010.86
5.1.60.0020.02010.55
5.1.50.0020.01710.55
5.1.40.0030.02810.56
5.1.30.0050.02810.75
5.1.20.0050.02810.72
5.1.10.0030.02910.55
5.1.00.0030.02810.61
5.0.50.0020.02110.55
5.0.40.0000.02110.55
5.0.30.0040.02510.55
5.0.20.0010.02810.55
5.0.10.0030.01410.55
5.0.00.0030.01610.55
4.4.90.0020.01210.55
4.4.80.0010.01110.55
4.4.70.0020.01210.55
4.4.60.0030.01610.55
4.4.50.0000.02010.55
4.4.40.0000.03310.55
4.4.30.0000.02110.55
4.4.20.0000.02110.55
4.4.10.0050.01610.55
4.4.00.0030.02210.55
4.3.110.0020.01210.55
4.3.100.0000.01910.55
4.3.90.0000.01110.55
4.3.80.0030.01310.55
4.3.70.0010.01010.55
4.3.60.0000.01010.55
4.3.50.0010.01010.55
4.3.40.0030.01410.55
4.3.30.0010.00910.55
4.3.20.0000.01010.55
4.3.10.0020.00810.55
4.3.00.0000.01110.55

preferences:
49.91 ms | 401 KiB | 5 Q