DEV Community

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

Posted on • Edited 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)