$result = DB::table('customer')->where('isp',2)->get();
// start_date is stored date in database
$date= $result->start_date;
$dts = Carbon::create($date);
// in order to get the last day of relative month
// get the last day of month for instance is equal to 2010-09-30 00:00:00
// find the difference between in days
}
当我从Laravel的diffindays
使用时,输出为0。为什么有任何想法?
答案 0 :(得分:0)
因此,您需要在几天之内与$result->start_date
和$last
进行比较。
您可以尝试这样:
$start = Carbon::parse($result->start_date);
$last = Carbon::parse($last);
$difference = $start->diff($last)->days;
如果您有$result->start_date (2010-09-03 00:00:00)
和$last (2010-09-30)
,这应该可以工作。