簡體   English   中英

使用 Carbon 獲取上個月的最后 5 天

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM