我只想使用碳来获取上个月的最后5天
我正在使用此代码获取上个月的最后一天
$lastDay = new Carbon('last day of last month')
我已经在互联网上搜索,但是找不到答案
答案 0 :(得分:0)
我已经对此有了答案
$lastDay = new Carbon('last day of last month');
$lastMonthDays = [];
$lastDays = $lastDay->format('d') - 5;
$day = $lastDay->format('d');
for($i = $lastDays +1 ; $i <= $day; $i++){
$lastMonthDays[] = $i;
}