echo date("Y-n-j", strtotime("first day of previous month"));
echo date("Y-n-j", strtotime("last day of previous month"));
echo date("Y-n-j", strtotime("first day of previous month previous month")); // 两个月前
echo date("Y-n-j", strtotime("last day of previous month previous month"));// 两个月前
返回上两个月的所有日期
$lastday = date("Y-n-j", strtotime("last day of previous month previous month"));// 两个月前
$dayarr = [];
$dayend = explode('-',$lastday);
$days_of_month = cal_days_in_month(CAL_GREGORIAN, $dayend[1], $dayend[0]);
for($i=1; $i<=$days_of_month;$i++){
$dayarr[] = $dayend[0] .'-' .$dayend[1] . '-' . $i;
}
return $dayarr;
php 1个月前日期 php 2个月前 日期
最新推荐文章于 2024-03-07 15:51:01 发布