DEV Community 👩‍💻👨‍💻

Cover image for Laravel 9 - Eloquent Date Methods
Sandro Jhuliano Cagara
Sandro Jhuliano Cagara

Posted on • Updated on

Laravel 9 - Eloquent Date Methods

In Eloquent, you can use the date functions like: whereDay(), whereMonth(), whereYear(), whereDate() and whereTime().

User::whereDate('created_at', '2022-05-31')->get();
User::whereMonth('created_at', '5')->get();
User::whereDay('created_at', '31')->get();
User::whereYear('created_at', date('Y'))->get();
User::whereTime('created_at', '=', '12:12:12')->get();
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Update Your DEV Experience Level:


Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠