Friday, August 29, 2025
HomeLanguagesLaravel Eloquent whereTime Query Example

Laravel Eloquent whereTime Query Example

Laravel provides numerous eloquent methods, and you can use different eloquent methods for a different purposes.

But In this laravel tutorial, you will learn about whereTime eloquent method. As well as how to use this eloquent method with laravel query builder and model.

When you develop any application in laravel, and you want to fetch records of specific time only. At that time, you can use laravel whereTime() eloquent method with query.

Here you will see many examples of laravel whereTime method:

Example 1: whereTime method with query builder

$users = DB::table('users')
             ->whereTime('created_at', '=', '09:50:11')
             ->get();
dd($users);

Example 2: whereTime method with eloquent model

$users = User::whereTime('created_at', '=', '09:50:11')
             ->get();
dd($users);

The whereTime query will compare a column’s value against a given specific time in this. And the get result accordingly.

When you dump the above given whereTime query you will get the following SQL query:

select * from `users` where time(`created_at1`) = 09:50:11

And you can also write this whereTime query without operator as follow:

$users = User::whereTime('created_at1', '09:50:11')->get();
dd($users);
RELATED ARTICLES

Most Popular

Dominic
32249 POSTS0 COMMENTS
Milvus
80 POSTS0 COMMENTS
Nango Kala
6615 POSTS0 COMMENTS
Nicole Veronica
11789 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11837 POSTS0 COMMENTS
Shaida Kate Naidoo
6731 POSTS0 COMMENTS
Ted Musemwa
7011 POSTS0 COMMENTS
Thapelo Manthata
6687 POSTS0 COMMENTS
Umr Jansen
6699 POSTS0 COMMENTS