3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $month = 2; //date("n"); $day = 16; //date("j"); $year = 2014; //date("Y"); if ($day > 15) { $day = 1; } else { if ($month == 1) { $month = 12; $year--; $day = 16; } else { $month--; $day = 16; } } $daysinmonth = date("t", strtotime("$year - $month - $day")); //$rangeEnd = date("Y-m-d 23:59:59", strtotime("last month")); //$rangeStart = date("Y-m-d 00:00:00", strtotime($rangeEnd." -6 days")); echo "$year $month $day $daysinmonth"; ?>
Output for 4.3.0 - 7.1.0
2014 2 1 31