<?php
//获取下月第一天
function getNextmonthFirstday($date) {
$year = substr($date, 0, 4);
$month = substr($date, 5, 2);
$D = date('Y-m-d', mktime(0, 0, 0, $month + 1, 1, $year));
return $D;
}
$last_month_first_day = getNextmonthFirstday("2017-11-01");//2017-10-01
//获取所属月的最后一天
$a = "2017-09-06";
date('Y-m-d', strtotime("$a +1 month -1 day"));