3v4l.org

run code in 500+ PHP versions simultaneously
<?php $start = new DateTime("-2 months"); $end = clone $start; $start->modify("first day of this month"); $end->modify("last day of this month"); echo $start->format("Y-m-d")." - ".$end->format("Y-m-d");
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
2022-05-01 - 2022-05-31

preferences:
96.05 ms | 1691 KiB | 4 Q