3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('Europe/Prague'); $tz = new \DateTimeZone('UTC'); $date = new \DateTime('2016-05-05 midnight', $tz); echo $date->format('c'); echo PHP_EOL; $date->modify('first day of this month midnight'); $date->modify('-2 months'); $date->modify('last day of this month'); echo $date->format('c');
Output for 5.6.0 - 5.6.24, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
2016-05-05T00:00:00+00:00 2016-03-31T00:00:00+00:00

preferences:
214.77 ms | 403 KiB | 228 Q