범위 쿼리를 작성 중이며 fetch_date
을 전달하여 created_at
타임 스탬프를 기반으로 DB 테이블의 항목을 가져옵니다.변수를 업데이트 할 때 Laravel 날짜가 변경됨
는 한 달에 대한 모든 기록을 찾기 위해 노력하고있어,하지만 난 다음 시도 할 때마다 변수 $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 변수에 한 달 추가하는 것으로 보입니다. 복사 한 다음 월을 추가하십시오. –