Php 获取上一个月或者下一个月时间参考

function GetMonth($sign="1")
{
//得到系统的年月
$tmp_date=date("Ym");
//切割出年份
$tmp_year=substr($tmp_date,0,4);
//切割出月份
$tmp_mon =substr($tmp_date,4,2);
$tmp_nextmonth=mktime(0,0,0,$tmp_mon+1,1,$tmp_year);
$tmp_forwardmonth=mktime(0,0,0,$tmp_mon-1,1,$tmp_year);
if($sign==0){
//得到当前月的下一个月
return $fm_next_month=date("Ym",$tmp_nextmonth);
}else{
//得到当前月的上一个月
return $fm_forward_month=date("Ym",$tmp_forwardmonth);
}
}

原文地址:https://www.cnblogs.com/zfeng/p/4103036.html