Friday, October 17, 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
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS