Laravel日期改變我正在寫一個範圍查詢,我傳遞一個fetch_date
從基礎上created_at
時間戳DB表拉東西。當我更新變量
我試圖尋找了一個月的所有記錄,但變量$fetch_date
不斷變化,每當我嘗試以下方法:
//$fetch_date is a carbon instance and is equal to the month the user selected
//ie: Carbon {#221 ▼
// +"date": "2016-07-01 00:00:00.000000"
//Create the next_month
$next_month = $fetch_date->addMonth();
//Format next_month as a string
$next_month = $next_month->format('Y-m-d');
//Format fetch_date as a string
$fetch_date = $fetch_date->format('Y-m-d');
dd($fetch_date);
//This now gives me 2016-08-01 - why?
爲什麼會出現fetch_date
變化?我基本上試圖保持$fetch_date
當前月份和$next_month
僅僅是下個月的開始。
我猜有一個真正的原因很簡單,這個我只是遠眺。
我想一個月要添加到fetch_date變量。嘗試複製它,然後添加月份。 –