/**
* 计算指定日期的前N个月日期
* @param type $time
* @param int $month_length
* @return date
*/
public function calLMP($time,$month_length ){
$r = date(‘Y-m-d‘,strtotime(‘-‘.$month_length.‘month‘,strtotime($time)));
list($ey,$em,$ed) = explode(‘-‘,$time);
list($ry,$rm,$rd) = explode(‘-‘,$r);
//关键就是这里。
$ml = $em-$rm;
if($ml==($month_length%12 - 1)||($ml+12)==($month_length%12 - 1))
{
$rm--;
$rd = 30-$rd;
$r = $ry.‘-‘.$rm.‘-‘.$rd;
}
return $r;
}
时间: 2024-12-14 04:43:03