//生成当年12个月年月日($id是0代表今年,1代表减1年,2代表减2年)
public static function ymt($id){
//获得当点12个月的年月日
$yuef = [];
$currentTime = time();
$cyear = floor(date("Y",$currentTime))-$id;
$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));//当月第一天(年月日)
//日期转时间戳
$t1 = strtotime($firstday);//时间戳
$yuef[]=[$t1,$firstday];
}
return $yuef;
}