复制代码
public static function get_year_to_curtime($currTime,$month,$isDay = 1)
{
$currY = date('Y',$currTime);
$currM = date('m',$currTime);
$day = date('d',$currTime);
$futureYm=strtotime('+'.$month.'month',strtotime($currY.'-'.$currM));
$futureMonthTotalDay = date( 't',$futureYm);
if ($day > $futureMonthTotalDay){
$day = $futureMonthTotalDay;
}
// 需求29409 解决商城与DMS时间不一致问题,DMS为前一天,因此商城也需要往前推一天
return strtotime(date('Y-m',$futureYm).'-'.$day.'23:59:59') - 86400;
}
复制代码
方法二:
public static function get_year_to_curtime($currTime,$month)
{
$currY = date('Y',$currTime);
$currM = date('m',$currTime);
$currD = date('d',$currTime);
$nextY = $currY;
$nextM = $currM + $month;
if ($nextM > 12){
$nextM = $nextM%12;
$nextY = intval($nextM/12) + $currY;
}
if (in_array($nextM,[1,3,5,7,8,10,12]) && in_array($currD,[28,29,30,31])){
$nextD = 31;
}elseif(in_array($nextM,[4,6,7,9,11]) && in_array($currD,[28,29,30,31])){
$nextD = 30;
}elseif($nextM == 2 && in_array($currD,[28,29,30,31])){
$nextD = date("t", mktime(20,20,20,2,1,$nextY));
}else{
$nextD = $currD;
}
return strtotime($nextY.'-'.$nextM.'-'.$nextD);
}