【发布时间】:2018-11-19 03:32:54
【问题描述】:
当我在日期之间运行我的日期范围过滤器时,没有数据显示,但在我的数据库中我有这些数据。
注意: 如果你知道如何使用碳,请在下面说明,谢谢。
例如:从 1-5-2018 到 31-5-2018 什么都不会显示,请看下图
控制器:
if ($request->has('from') && $request->has('to')) {
$from = date('d-M-Y', strtotime($request->get('from')));
$to = date('d-M-Y', strtotime($request->get('to')));
$leads = Lead::whereBetween('created_at', [$from, $to])->paginate(5);
}
【问题讨论】:
-
确保在
whereBetween()中,较小的日期放在首位,而不是较大的日期 -
是的,但数据仍然是空的..
-
数据库和变量中的日期格式是否相同?
-
im 使用我的 sql 默认格式 yyyy-mm-dd
-
在你的变量中?
标签: php laravel random laravel-5.5