//解决比如3月31号加一个月变成5月1号等问题
$time = time();
//当前月份中的第几天
$day = date(‘j‘,$time);
//这个月的天数
$month_day = date(‘t‘,$time);
//这个月的第一天
$first_day_of_month_time = strtotime(date(‘Y-m-01 H:i:s‘,$time));
//下个月的第一天
$first_day_of_next_month_time = strtotime("+1 month",$first_day_of_month_time);
//下个月的天数
$next_month_day = date(‘t‘,$first_day_of_next_month_time);
//如果下个月的天数小于这个月当前天数
if($next_month_day<$day){
$next_month = date("Y-m-t",$first_day_of_next_month_time );
}else{
$next_month = date(‘Y-m-d‘,strtotime("+1 month",$time));
}
原文:http://my.oschina.net/u/1029242/blog/360054