I need to compare the dates from my database with the current day. This id my code, in eloquent:
$posts = Post::where('date', '=', date('Y-m-d'))->get();
I want to retrieve today's posts only.
Knowing that the 'date' field is of type Date, How do I make this work?
I tried to convert date('Y-m-d')
to string with the 'format' method, but it seems that date('Y-m-d')
is somehow returning a Boolean, and thus, the method 'format' can't be applied to it..