3v4l.org

run code in 300+ PHP versions simultaneously
<?php $thirtyOnedayMonths = array( 1, 3, 5, 7, 8, 10, 12 ); $oneMonth = new \DateInterval('P1M'); $format = 'Y-m-d'; foreach($thirtyOnedayMonths as $month){ $date = date($format, strtotime('-1 month', strtotime("2013-{$month}-31 00:00:01"))); var_dump($date); }

preferences:
41.44 ms | 402 KiB | 5 Q