foreach(range(2014, 2015) as $year){ foreach(range(1, 12) as $month){ echo date('Y.m.d', strtotime('Last day of ' . date('F', strtotime($year . '-' . $month . '-01')) . $year)) . PHP_EOL; } }