当月第一天
date('Y-m-01');
当月最后一天
date('Y-m-t');
指定月份第一天
$date = '2022-05-12' ;
$firstDay = date('Y-m-01', strtotime($date));
每月最后一天
//第一种
$date = '2022-05-12';
$lastDay = date('Y-m-d', strtotime(date('Y-m-01', strtotime($date)). ' +1 month -1 day'));
//第二种
$firstDay = date('Y-m-01', strtotime($date));
$lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day"));
//第三种
$lastDay = date('Y-m-t',strtotime($date)));
Comments NOTHING