Laravel: Select Records Created That Day

I have a model Laravel, Users. It uses the standard Laravel timestamp: created_atand updated_at.

I want to find users created on the same day as this user.

The problem is that I can not directly compare database fields, because these fields also contain the time, for example 2016-03-27 14:46:30.

I want to do something like this:

User::where('created_at', $user->created_at);

But it seems that this is not so.

Any suggestions?

+4
source share
1 answer

Instead, use the whereDatecondition:

$q->whereDate('created_at', '=', $your_date);

Hope this helps.

+5
source

All Articles