3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Get Dates In Month. * * @updated 2022-12-15 19:09:31 +07:00 * * @param bool|string $yearmonth * true = current year/month * string = other year/month * * @note If using PHP < 8, remove the bool|string union type signature! * @return array */ function get_dates_in_month(bool|string $yearmonth): array { /* If for current year/month */ if($yearmonth === true) { $base = date('Y-m'); // Current base date $days = range(1, date('d')); // Days from 1 to now } /* If for other year/month */ else { $base = $yearmonth; // Literal base date $days = range(1, date('t', strtotime($yearmonth))); // Days from 1 to month max } /* Combine with day added */ $dates = array_map(function($day) use ($base) { return $base . '-' . str_pad((string) $day, 2, "0", STR_PAD_LEFT); }, $days); return $dates; } echo "==== Current Y/M ====\n"; var_dump(get_dates_in_month(true)); echo "==== Other Y/M ====\n"; var_dump(get_dates_in_month('1980-02'));

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.00.0110.01220.17
8.4.150.0020.00114.05
8.4.140.0140.00817.66
8.4.130.0130.00818.59
8.4.120.0120.00824.08
8.4.110.0130.00820.59
8.4.100.0130.00618.11
8.4.90.0130.00819.09
8.4.80.0090.01219.63
8.4.70.0100.01118.08
8.4.60.0110.00919.04
8.4.50.0080.00620.50
8.4.40.0090.01219.58
8.4.30.0130.00618.67
8.4.20.0130.00725.90
8.4.10.0130.00323.92
8.3.280.0130.00820.31
8.3.270.0100.00916.80
8.3.260.0050.00916.54
8.3.250.0110.00518.59
8.3.240.0070.00417.27
8.3.230.0130.00716.79
8.3.220.0060.00217.21
8.3.210.0100.00916.61
8.3.200.0040.00516.80
8.3.190.0100.00817.25
8.3.180.0060.01516.44
8.3.170.0160.00317.16
8.3.160.0120.00618.45
8.3.150.0090.00918.89
8.3.140.0080.00016.93
8.3.130.0160.00018.48
8.3.120.0060.00320.91
8.3.110.0030.00620.94
8.3.100.0040.00416.48
8.3.90.0050.00326.77
8.3.80.0040.00718.68
8.3.70.0120.00916.88
8.3.60.0130.00318.43
8.3.50.0100.00718.30
8.3.40.0150.00020.02
8.3.30.0110.00418.84
8.3.20.0050.00324.18
8.3.10.0080.00024.66
8.3.00.0000.00826.16
8.2.290.0120.00722.11
8.2.280.0090.00718.69
8.2.270.0160.00319.05
8.2.260.0030.01519.05
8.2.250.0030.00716.70
8.2.240.0130.00319.21
8.2.230.0080.00322.58
8.2.220.0030.00624.06
8.2.210.0040.00426.77
8.2.200.0060.00316.63
8.2.190.0100.01316.88
8.2.180.0140.00425.92
8.2.170.0100.00622.96
8.2.160.0090.00922.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0000.00726.16
8.2.120.0030.01020.66
8.2.110.0060.00320.39
8.2.100.0100.00319.10
8.2.00.0010.00717.95
8.1.330.0090.00922.13
8.1.320.0110.01016.45
8.1.310.0080.00017.06
8.1.300.0030.00616.41
8.1.290.0060.00330.84
8.1.280.0150.00925.92
8.1.270.0040.00424.66
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0060.00620.48
8.1.230.0030.00618.73

preferences:
32.68 ms | 403 KiB | 5 Q