Reputation: 233
Following the examples found here on stack overflow I'm trying to do this:
$users = User::where('updated_at', '>', time() - (5))->get();
As the title of the post, I would like to receive only the records where the field "updated_at" is not older than 5 seconds. I also tried something like that:
...where('updated_at', '<', DB::raw('(NOW(), INTERVAL 5 SECOND)'))...
or
...where('updated_at', '>=', time() - (1*1*5))->get();
but keeps giving me even the obsolete records...
Upvotes: 2
Views: 5431
Reputation: 87789
This way:
$users = User::where('updated_at', '>', \Carbon\Carbon::now()->subSeconds(5)->toDateTimeString())->get();
Upvotes: 11