3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDates(DateTime $date) { $day = $date->format('d'); if ($day == 20) { $nextMonth = clone $date; $nextMonth->modify('-1 day'); $nextMonth->modify('+1 month'); return [ 'start' => $date, 'end' => $nextMonth, ]; } else if ($day == 19) { $lastMonth = clone $date; $lastMonth->modify('+1 day'); $lastMonth->modify('-1 month'); return [ 'start' => $lastMonth, 'end' => $date, ]; } elseif ($day > 20) { $start = new DateTime($date->format('Y-m-20 H:i:s')); } else { $start = new DateTime($date->format('Y-m-20 H:i:s')); $start->modify('-1 month'); } $end = clone $start; $end->modify('+1 month'); $end->modify('-1 day'); return [ 'start' => $start, 'end' => $end, ]; } $date = new DateTime('2017-09-20'); var_dump(getDates($date)); $date = new DateTime('2017-09-19'); var_dump(getDates($date)); $date = new DateTime('2017-09-15'); var_dump(getDates($date)); $date = new DateTime('2017-08-23'); var_dump(getDates($date));

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.00916.88
8.3.50.0130.00316.61
8.3.40.0090.00618.84
8.3.30.0060.01218.98
8.3.20.0040.00420.34
8.3.10.0040.00420.51
8.3.00.0080.00023.66
8.2.180.0120.00618.63
8.2.170.0110.00822.96
8.2.160.0150.00420.38
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0090.00026.16
8.2.120.0060.00321.06
8.2.110.0060.00322.43
8.2.100.0000.01218.16
8.2.90.0050.00319.38
8.2.80.0040.00418.05
8.2.70.0060.00317.88
8.2.60.0000.00918.18
8.2.50.0080.00018.22
8.2.40.0060.00320.55
8.2.30.0000.00819.39
8.2.20.0040.00418.29
8.2.10.0040.00418.18
8.2.00.0040.00418.30
8.1.280.0110.01125.92
8.1.270.0040.00420.76
8.1.260.0080.00026.35
8.1.250.0060.00328.09
8.1.240.0030.00624.11
8.1.230.0100.00718.02
8.1.220.0040.00417.93
8.1.210.0040.00418.77
8.1.200.0000.01017.60
8.1.190.0030.00517.61
8.1.180.0000.00918.10
8.1.170.0040.00418.64
8.1.160.0000.00818.95
8.1.150.0000.00820.26
8.1.140.0040.00419.59
8.1.130.0060.00319.07
8.1.120.0050.00217.65
8.1.110.0050.00317.65
8.1.100.0000.00817.75
8.1.90.0000.00917.63
8.1.80.0040.00417.75
8.1.70.0000.00717.81
8.1.60.0040.00417.85
8.1.50.0090.00017.74
8.1.40.0040.00417.77
8.1.30.0060.00317.93
8.1.20.0000.00817.78
8.1.10.0030.00617.66
8.1.00.0030.00617.81
8.0.300.0050.00320.08
8.0.290.0050.00317.00
8.0.280.0040.00418.53
8.0.270.0000.00717.26
8.0.260.0000.00718.80
8.0.250.0030.00317.32
8.0.240.0040.00417.32
8.0.230.0040.00417.37
8.0.220.0030.00517.30
8.0.210.0080.00017.24
8.0.200.0030.00317.23
8.0.190.0040.00417.22
8.0.180.0000.00817.29
8.0.170.0000.00717.16
8.0.160.0000.00817.25
8.0.150.0000.01117.26
8.0.140.0030.00517.27
8.0.130.0070.00013.58
8.0.120.0040.00417.20
8.0.110.0040.00417.26
8.0.100.0060.00317.23
8.0.90.0030.00617.30
8.0.80.0070.00717.27
8.0.70.0030.00517.14
8.0.60.0040.00417.09
8.0.50.0050.00317.25
8.0.30.0090.01417.37
8.0.20.0120.01317.41
8.0.10.0040.00417.50
8.0.00.0160.00317.06
7.4.330.0020.00215.55
7.4.320.0000.00616.74
7.4.300.0040.00416.75
7.4.290.0030.00316.89
7.4.280.0030.00316.75
7.4.270.0040.00416.76
7.4.260.0030.00316.75
7.4.250.0000.01016.70
7.4.240.0000.00716.76
7.4.230.0040.00416.78
7.4.220.0160.01016.60
7.4.210.0100.00816.78
7.4.200.0000.00716.74
7.4.160.0150.00616.83
7.4.150.0090.00917.40
7.4.140.0140.01017.86
7.4.130.0170.00916.64
7.4.120.0140.00816.87
7.4.110.0150.00316.77
7.4.100.0130.00616.75
7.4.90.0100.00916.84
7.4.80.0140.00819.39
7.4.70.0130.00616.85
7.4.60.0150.00416.84
7.4.50.0120.00617.04
7.4.40.0090.00916.55
7.4.30.0140.00416.75
7.4.00.0000.01515.43
7.3.330.0000.00513.59
7.3.320.0050.00013.46
7.3.310.0000.00816.59
7.3.300.0030.00316.66
7.3.290.0030.00316.47
7.3.280.0080.00916.57
7.3.270.0140.00617.40
7.3.260.0110.00816.75
7.3.250.0110.01016.75
7.3.240.0110.00816.66
7.3.230.0140.00516.56
7.3.210.0110.00816.78
7.3.200.0030.01416.84
7.3.190.0080.01116.64
7.3.180.0090.00916.72
7.3.170.0140.01016.53
7.3.160.0030.01516.80
7.2.330.0140.00416.86
7.2.320.0080.01416.89
7.2.310.0100.00716.96
7.2.300.0210.00316.68
7.2.290.0060.01116.82
7.2.60.0170.01217.09
7.1.200.0070.00715.91
7.1.90.0030.01018.34
7.1.80.0060.00918.16
7.1.70.0100.00917.45
7.1.60.0190.00935.35
7.1.50.0100.01935.13
7.1.40.0180.00934.80
7.1.30.0170.01034.80
7.1.20.0130.02034.65
7.1.10.0030.01116.61
7.1.00.0080.00516.96
7.0.230.0030.01017.69
7.0.220.0030.01017.97
7.0.210.0040.01116.69
7.0.200.0100.00317.12
7.0.190.0060.00616.59
7.0.180.0000.01416.32
7.0.170.0030.01116.70
7.0.160.0080.00516.30
7.0.150.0030.01016.59
7.0.140.0030.01016.38
7.0.130.0090.00816.56
7.0.120.0040.00816.79
7.0.110.0030.01016.51
7.0.100.0080.00516.42
7.0.90.0030.01016.48
7.0.80.0080.00516.64
7.0.70.0070.00716.32
7.0.60.0100.00816.41
7.0.50.0070.01116.51
7.0.40.0060.00916.53
7.0.30.0070.00716.65
7.0.20.0080.01016.59
7.0.10.0100.00816.66
7.0.00.0000.01316.44

preferences:
61.4 ms | 401 KiB | 5 Q