得到当前月的下一个月或上一个月的今天

 //上一个月的今天 格式为 "2014-09-23 10:05:09"
 $forward_month= GetMonth($sign="-1");

 //得到当前月的下一个月或上一个月的今天
 function GetMonth($sign="-1")  
 {  
  //得到系统的日 
  $day_now=date("d",strtotime("now"));
  //得到系统的年月  
  $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==1){  
   //得到当前月的下一个月   
   $fm_next_month=date("Y-m",$tmp_nextmonth);
   return $fm_next_month=$fm_next_month.'-'. $day_now;        
  }
  if($sign==-1){  
   //得到当前月的上一个月   
   $fm_forward_month=date("Y-m",$tmp_forwardmonth);
   return $fm_forward_month=$fm_forward_month.'-'. $day_now;             
  }else{  
   return $date_now=date("Y-m-d",strtotime("now"));//当前日期
  }  
 } 

原文地址:https://www.cnblogs.com/hailexuexi/p/3988623.html