php獲取當前月份的前(后)幾個月


//獲取當前月份的前一月
function GetMonth($sign)  
{  
    //得到系統的年月  
    $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+$sign,1,$tmp_year);  
    // 得到當前月份的前幾月
    $tmp_forwardmonth=mktime(0,0,0,$tmp_mon-$sign,1,$tmp_year);  
        return $fm_next_month=date("Ym",$tmp_forwardmonth);          
    } 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM