//获得当点12个月的年月日
$yuef = [];
$currentTime = time();
$cyear = floor(date("Y",$currentTime));
$cMonth = floor(date("1",$currentTime));
for($i=0;$i<12;$i++){
$nMonth = $cMonth+$i;
$cyear = $nMonth == 0 ? ($cyear-1) : $cyear;//年
$nMonth = $nMonth <= 0 ? 12+$nMonth : $nMonth;//月
$date = $cyear."-".$nMonth."-1";
$firstday = date('Y-m-01', strtotime($date));//当月第一天(年月日)
$lastday = date('Y-m-t', strtotime($date));//当月最后阳台(年月日)
$t = date('t', strtotime($date));//一个月有多少天
//日期转时间戳
$t1 = strtotime($lastday);//结束
// $t3 = date('Y-m-t',$t1);
$yuef[]=[$t1,$t,$firstday,$lastday];
}
return $yuef;
|