使用Carbon获取上个月的最后5天

我只想使用碳来获取上个月的最后5天

我正在使用此代码获取上个月的最后一天

$lastDay = new Carbon('last day of last month')

我已经在互联网上搜索,但是找不到答案

bestd 回答:使用Carbon获取上个月的最后5天

我已经对此有了答案

$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;
}
本文链接:https://www.f2er.com/3155439.html

大家都在问