3v4l.org

run code in 500+ PHP versions simultaneously
<?php function diffInMonth(DateTime $start,DateTime $end): int { list($yearStart,$monthStart,$dayStart) = explode(" ",$start->format("Y m dHis")); list($yearEnd,$monthEnd, $dayEnd) = explode(" ",$end->format("Y m dHis")); $mothDiff = ($yearEnd - $yearStart) * 12 + $monthEnd - $monthStart; if($dayStart > $dayEnd) --$mothDiff; return $mothDiff; } $startDate = new DateTime('2022-11-01 00:00:00.0', new DateTimeZone('Africa/Nairobi')); $endDate = new DateTime('2022-12-01 00:00:00.0', new DateTimeZone('Africa/Nairobi')); $month = diffInMonth($startDate, $endDate); echo $month;

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.5.70.0090.00817.22
8.5.60.0130.00517.01
8.5.50.0080.00718.72
8.5.30.0100.00821.42
8.5.20.0120.00719.94
8.5.10.0020.00522.15
8.5.00.0090.01220.39
8.4.210.0130.00919.66
8.4.180.0180.00619.95
8.4.170.0120.01020.64
8.4.160.0120.01021.68
8.4.150.0070.00516.86
8.4.140.0130.01018.16
8.4.130.0100.00720.11
8.4.120.0090.00722.52
8.4.110.0160.00422.64
8.4.100.0120.00918.29
8.4.90.0120.00918.96
8.4.80.0050.00324.65
8.4.70.0110.00918.22
8.4.60.0100.00819.15
8.4.50.0070.00226.00
8.4.40.0100.01018.12
8.4.30.0200.00020.89
8.4.20.0000.00818.39
8.4.10.0030.01324.06
8.3.300.0130.00918.73
8.3.290.0090.01321.13
8.3.280.0150.00518.95
8.3.270.0110.01017.09
8.3.260.0120.00516.63
8.3.250.0110.00719.28
8.3.240.0150.00417.31
8.3.230.0080.00816.96
8.3.220.0060.00817.61
8.3.210.0040.00319.02
8.3.200.0040.00516.79
8.3.190.0100.00917.51
8.3.180.0090.01017.06
8.3.170.0090.00917.70
8.3.160.0090.00916.94
8.3.150.0070.01117.56
8.3.140.0000.01518.80
8.3.130.0030.00616.76
8.3.120.0080.00021.07
8.3.110.0050.00317.25
8.3.100.0030.00616.81
8.3.90.0000.00826.77
8.3.80.0100.00016.88
8.3.70.0130.00316.75
8.3.60.0150.00418.81
8.3.50.0140.00720.27
8.3.40.0030.01020.56
8.3.30.0120.00319.11
8.3.20.0000.00824.18
8.3.10.0080.00024.66
8.3.00.0080.00026.16
8.2.300.0130.00722.32
8.2.290.0130.00520.43
8.2.280.0070.01218.64
8.2.270.0040.00418.59
8.2.260.0110.00719.28
8.2.250.0030.00518.50
8.2.240.0060.00317.26
8.2.230.0100.00720.94
8.2.220.0030.00524.06
8.2.210.0000.01026.77
8.2.200.0100.00018.90
8.2.190.0110.00417.11
8.2.180.0150.00625.92
8.2.170.0120.00322.96
8.2.160.0070.00722.96
8.2.150.0050.00325.66
8.2.140.0030.00624.66
8.2.130.0050.00226.16
8.2.120.0070.00021.18
8.2.110.0030.00621.00
8.2.100.0080.00418.22
8.2.90.0040.00418.13
8.2.80.0040.00419.16
8.2.70.0000.00818.25
8.2.60.0000.00818.13
8.2.50.0040.00418.11
8.2.40.0060.00619.85
8.2.30.0040.00418.38
8.2.20.0040.00419.58
8.2.10.0000.00718.41
8.2.00.0000.00819.70
8.1.340.0120.00818.07
8.1.330.0060.00224.18
8.1.320.0110.00916.82
8.1.310.0080.00017.06
8.1.300.0050.00517.05
8.1.290.0030.00630.84
8.1.280.0090.00625.92
8.1.270.0090.00023.86
8.1.260.0000.00826.35
8.1.250.0050.00228.09
8.1.240.0030.00619.39
8.1.230.0000.01221.19
8.1.220.0000.00817.85
8.1.210.0060.00318.77
8.1.200.0060.00317.90
8.1.190.0040.00417.60
8.1.180.0000.00918.10
8.1.170.0000.00717.72
8.1.160.0040.00419.06
8.1.150.0070.00018.97
8.1.140.0000.00817.77
8.1.130.0070.00019.23
8.1.120.0110.00217.83
8.1.110.0080.00317.84
8.1.100.0110.00517.84
8.1.90.0150.00017.83
8.1.80.0120.00317.82
8.1.70.0150.00217.81
8.1.60.0050.00817.68
8.1.50.0090.00417.76
8.1.40.0130.00117.83
8.1.30.0050.00917.90
8.1.20.0130.00217.85
8.1.10.0130.00517.82
8.1.00.0040.00617.78
8.0.300.0050.00318.77
8.0.290.0040.00417.13
8.0.280.0000.00718.63
8.0.270.0040.00418.57
8.0.260.0030.00318.72
8.0.250.0130.00417.44
8.0.240.0090.00517.48
8.0.230.0090.00717.39
8.0.220.0110.00417.27
8.0.210.0090.00717.37
8.0.200.0060.00917.42
8.0.190.0090.00617.38
8.0.180.0110.00517.31
8.0.170.0030.01017.38
8.0.160.0130.00117.28
8.0.150.0080.00617.26
8.0.140.0090.00617.26
8.0.130.0080.00817.23
8.0.120.0110.00417.19
8.0.110.0110.00317.40
8.0.100.0130.00117.36
8.0.90.0080.00717.31
8.0.80.0130.00117.26
8.0.70.0130.00317.13
8.0.60.0090.00617.32
8.0.50.0120.00217.26
8.0.30.0120.00417.35
8.0.20.0090.00617.39
8.0.10.0100.00617.50
7.4.330.0030.00315.55
7.4.320.0130.00416.95
7.4.300.0120.00616.84
7.4.290.0130.00416.76
7.4.280.0090.00816.86
7.4.270.0070.00716.95
7.4.260.0110.00416.95
7.4.250.0110.00716.87
7.4.240.0090.00816.79
7.4.230.0110.00516.87
7.4.220.0100.00516.87
7.4.210.0090.00617.00
7.4.200.0060.00816.80
7.4.190.0150.00016.98
7.4.180.0150.00016.85
7.4.160.0090.00616.92
7.4.150.0100.00516.79
7.4.140.0080.00616.80
7.4.130.0100.00516.87
7.4.120.0130.00116.90
7.4.110.0090.00716.81
7.4.100.0140.00116.91
7.4.90.0090.00416.77
7.4.80.0050.00416.85
7.4.70.0120.00016.87
7.4.60.0050.00616.91
7.4.50.0080.00516.86
7.4.40.0060.00516.83
7.4.30.0060.00616.82
7.4.20.0110.00216.78
7.4.10.0030.00916.88
7.4.00.0070.00316.90

preferences:
43.86 ms | 1244 KiB | 5 Q