我想只得到當前的日期和前dates.Here是我怎樣努力如何只獲取laravel中的當前日期和以前的日期?
$jobseekers = Calllog::orderBy('calllogs.created_at','DESC')
->get()->where('call_back_date', '<=', Carbon::today()->toDateString());
這個節目只有以前的日期,我想both.If我刪除「<」,它顯示只有當前的日期,請幫我。
我想只得到當前的日期和前dates.Here是我怎樣努力如何只獲取laravel中的當前日期和以前的日期?
$jobseekers = Calllog::orderBy('calllogs.created_at','DESC')
->get()->where('call_back_date', '<=', Carbon::today()->toDateString());
這個節目只有以前的日期,我想both.If我刪除「<」,它顯示只有當前的日期,請幫我。
$jobseekers = Calllog::orderBy('calllogs.created_at','DESC')->where('call_back_date', '<=', Carbon::now())->get();
現在使用(),而不是今天()。與today()不同,now()現在返回完整的日期時間。
另請注意,我在get()之前移動了條件,以防止從數據庫獲取額外數據。下面雄辯查詢
如果使用'now',則下一部分時間(當前時刻之後)的時間與條件不符。 –
使用tomorrow
和<
條件
$jobseekers = Calllog::orderBy('calllogs.created_at','DESC')
->get()->where('call_back_date', '<', Carbon::tomorrow()->toDateString());
使用
$jobseekers = Calllog::whereDate('call_back_date','<=',Carbon::today)->get()
'碳::今日()'返回00:00:00(小時和分鐘)今天幾號。試試'Carbon :: now()' –