[英]Get the last 5 days of last month using Carbon
我只想使用碳來獲取上個月的最后 5 天
我正在使用此代碼獲取上個月的最后一天
$lastDay = new Carbon('last day of last month')
我已經在互聯網上搜索,但我找不到答案
我已經有了答案
$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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.