首页 > 解决方案 > 没有给出完美的结果

问题描述

时间和日期都是不同的字段,但是当我使用这个编码时,结果并不完美。

这是我的代码:

$challenges = Challenge::whereDate('c_date','>',Carbon::now())->get();
Challenge::whereTime('c_time','>',Carbon::now())->get();

这段代码有问题吗?

标签: laravellaravel-5eloquentphp-carbon

解决方案


Firstly check the formate of date in c_date.Format should be ('Y-m-d').If your formate is okay then check your logic that what you really want? I think your fault is your logic .You want to get those date where c_date is grater then now date.

$challenges = Challenge::whereDate('c_date','<',Carbon::now())->get();


推荐阅读