3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $month = date("n"); $day = date("j"); $year = date("Y"); if ($day > 15) { $day = 1; } else { if ($month == 0) { $month = 12; $year--; } 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 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2014 6 16 31