用于显示上个月和下个月_PHP

/**
         * 用于显示上个月和下个月
         * @param int $sign 1:表示上个月 0:表示下个月
         * @return string
         */
        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/mssql8/p/3917370.html