3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function lastWeekDay($mnt) { $result = strtotime("1 $mnt"); $result = mktime(0, 0, 0, date('n', $result) + 1, 0, date('Y', $result)); while(in_array(date('D', $result), array('Sat', 'Sun'))) $result -= 86400; return $result; } foreach (array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec') as $month) { echo date('d-M-Y', lastWeekDay("$month 2013")) . "\n"; }
Output for 4.3.0 - 7.1.0
31-Jan-2013 28-Feb-2013 29-Mar-2013 30-Apr-2013 31-May-2013 28-Jun-2013 31-Jul-2013 30-Aug-2013 30-Sep-2013 31-Oct-2013 29-Nov-2013 31-Dec-2013