Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ifrit's avatar
Level 2

How to get all the data in the table with today's date

I'm trying to grab all my items that was created today, the issue I'm having is that I'm still getting yesterday's items. Here is my code

$items = Item::where('created_at', '>=', Carbon::today())->paginate(10);
0 likes
2 replies
laracoft's avatar

@ifrit Your code looks correct, the only bone I will pick is why >, you want the future's as well?

  1. Are the time zones the same for your MySQL and PHP?
  2. What are you getting for dd(Carbon::today())?
dani_fadli's avatar

I just tried this and it's returns the answer you expected. $items = Item::where('created_at', today());

1 like

Please or to participate in this conversation.