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变量。尝试复制它,然后添加月份。 –