$date = "2022-09-18"
获取日
$firstday = date('Y-m-d', strtotime("$date +0 day"));
$lastday = date("Y-m-d", strtotime("$date +1 day"));
获取周
$lastday = date("Y-m-d", strtotime("$date Sunday"));
$firstday = date("Y-m-d", strtotime("$lastday -6 days"));
获取月
$firstday = date("Y-m-01", strtotime($date));
$lastday = date("Y-m-d", strtotime("$firstday +1 month -1 day"));
获取季度
$season = ceil(date('n',strtotime($date)) /3);
$firstday = date('Y-m-01',mktime(0,0,0,($season - 1) *3 +1,1,date('Y')));
$lastday = date('Y-m-t',mktime(0,0,0,$season * 3,1,date('Y')));
标签:起止,season,firstday,strtotime,计算,date,lastday,php,day
From: https://www.cnblogs.com/fengzhipeng/p/16705455.html