Thursday, September 4, 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
32260 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6625 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6746 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6694 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS