php获取下月1号和月底最后一天的时间

2016-12-06  本文已影响0人  绫薍o
//获取下月1号和最后一天的时间

function getNextMonthDays($date){

$timestamp=strtotime($date);

$arr=getdate($timestamp);

if($arr['mon'] == 12){

$year=$arr['year'] +1;

$month=$arr['mon'] -11;

$firstday=$year.'-0'.$month.'-01';

$lastday=date('Y-m-d',strtotime("$firstday +1 month -1 day"));

}else{

$firstday=date('Y-m-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+1).'-01'));

$lastday=date('Y-m-d',strtotime("$firstday +1 month -1 day"));

}

return array($firstday,$lastday);

}

print_r(getNextMonthDays(date('Y-m-d')));

上一篇下一篇

猜你喜欢

热点阅读