php 根据输入的参数,获取上季度最后一个月的时间

public function getTime( $time ='2017-06-01 00:00:00'){

$month = date('m',strtotime($time));
$season = ceil($month/3);//当月是第几季度
$yeah =date('Y',strtotime($time)) ;
if($season ==1){
$oldYeah = intval($yeah-1) ;

$newTimeStart = $oldYeah."-12-01 00:00:00";
$newTimeEnd = $oldYeah."-12-31 23:59:59";
}else{
$newTimeStart = date('Y-m-d H:i:s',mktime(0, 0, 0,$season*3-3,1,date($yeah)));
$newTimeEnd = date('Y-m-d H:i:s',mktime(23,59,59,$season*3-3,date('t',mktime(0, 0, 0,$season*3-3,1,date($yeah))),date($yeah)));
}
var_dump($newTimeStart,$newTimeEnd);exit;
}
posted @ 2018-03-07 09:02  KOBE-Jason  阅读(469)  评论(0编辑  收藏  举报