【发布时间】:2016-10-24 00:09:53
【问题描述】:
我想从一个选定的日期(例如 10 小时前)获取所有结果,但它只会得到一个结果,我只能使用它来获得更多结果。
$sub10 = Carbon::yesterday(); // This works
$current_time = Carbon::now();
$sub10h = $current_time->subHours(10); // This doesn't
$transactionsFrom = Transaction::whereUserId($user_id)->whereDate('created_at', '>=', $sub10h)->get();
【问题讨论】:
-
你在
$sub10h有合适的时间吗? -
@JhonnyWalker "date": "2016-06-21 23:35:02" ,是的,时间应该是对的,我已经尝试过 subHours(24) ,但与昨天()我得到更多的地方
-
在这里出局。但是尝试
Carbon::now(-10)可能是subHours方法搞砸了
标签: laravel date time eloquent php-carbon