MeshWorld India LogoMeshWorld.

Laravel Eloquent whereTime() Method Explained

(Updated: Mar 27, 2026)
Listen to ArticleAI Speech
~5 min read narration
100%
Laravel Eloquent whereTime() Method Explained

whereTime() is a Laravel Eloquent query method that filters records by the time portion of a datetime column, ignoring the date. It’s the time-focused counterpart to whereDate(), available in Laravel 10, 11, and 12. Use it when you need records that were created or updated at a specific time of day — regardless of which calendar date that was.

What is the syntax for whereTime()?

The method signature mirrors whereDate(). Column name first, then an optional operator, then the time string. Omitting the operator defaults to =.

PHP
Model::whereTime('column', 'HH:MM:SS')->get();
// or with an explicit operator:
Model::whereTime('column', '>=', 'HH:MM:SS')->get();

The time string must be in HH:MM:SS format using a 24-hour clock. Laravel wraps the column in the database’s TIME() function before comparing, which strips the date portion.

When would I actually use whereTime()?

Scenario: You run a restaurant booking system. You want all bookings made between 6pm and 9pm, regardless of which day they were placed. whereTime() isolates the time component of the booked_at datetime column, so you can filter purely by hour of day without writing raw SQL.

Another common case: analytics. If your app tracks events with a timestamp, you can find peak activity hours without caring about dates — whereTime('created_at', '>=', '09:00:00')->whereTime('created_at', '<', '17:00:00') gives you everything during business hours.

How do I use comparison operators with whereTime()?

Pass the operator as the second argument. All standard SQL comparison operators work.

To get all records created at exactly 10:30:00:

PHP
$records = Log::whereTime('created_at', '=', '10:30:00')->get();

Records created after 5pm:

PHP
$evening = Order::whereTime('created_at', '>', '17:00:00')->get();

Records created before noon:

PHP
$morning = Order::whereTime('created_at', '<', '12:00:00')->get();

Records NOT created at midnight:

PHP
$nonMidnight = Event::whereTime('occurred_at', '<>', '00:00:00')->get();

All six operators in summary: =, <>, >, >=, <, <=.

How do I filter records within a time window?

Chain two whereTime() calls. This returns all bookings made between 6pm and 9pm (inclusive):

PHP
$eveningBookings = Booking::whereTime('booked_at', '>=', '18:00:00')
    ->whereTime('booked_at', '<=', '21:00:00')
    ->get();

Both conditions apply on the time portion only. A booking from any date qualifies as long as its time falls within the window.

You can also combine with whereDate() to filter both date and time. This query gets orders placed on a specific date during business hours:

PHP
use Carbon\Carbon;

$orders = Order::whereDate('created_at', '2025-12-25')
    ->whereTime('created_at', '>=', '09:00:00')
    ->whereTime('created_at', '<', '17:00:00')
    ->get();

How do I add OR time conditions?

Use orWhereTime(). Same parameters as whereTime().

This fetches records created either at midnight or at noon — useful for scheduled job logging:

PHP
$scheduledRuns = JobLog::whereTime('created_at', '00:00:00')
    ->orWhereTime('created_at', '12:00:00')
    ->get();

Summary

  • whereTime() filters by the time component of a datetime column, stripping the date before comparing
  • Time strings must be in HH:MM:SS (24-hour) format
  • Chain two whereTime() calls to define a time window
  • Combine with whereDate() when you need to filter by both date and time
  • Avoid on large unindexed tables — use datetime range queries with whereBetween() instead

FAQ

What format does whereTime() expect? HH:MM:SS in 24-hour format. 18:30:00 for 6

, 09:00:00 for 9am. There’s no AM/PM variant.

Can I pass only hours and minutes — like ‘18

’ instead of ‘18:30
’?
It depends on your database. MySQL accepts 18:30 and pads the seconds, but to be safe and portable, always include the seconds: 18:30:00.

Does whereTime() work with SQLite? SQLite has limited support for time functions. The TIME() function works in recent SQLite versions, but behavior may differ from MySQL or PostgreSQL. Test your queries if you’re running SQLite in production.

Is whereTime() available in Laravel 10, 11, and 12? Yes. It’s part of the Eloquent query builder and has been stable across all three major versions.

Can I combine whereDate() and whereTime() in the same query? Yes, absolutely. They’re independent clauses that both apply as AND conditions. This is the recommended way to filter by a specific date-time window.

Reader Quality Feedback

Did this technical guide help solve your problem?

Suggest Errata ($0)
Vishnu
Primary Author

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

Explore Author Archive
Compute Fuel & Open Testbed
100% Independent & Verified

Fuel High-Density, Zero-Fluff Engineering Deep-Dives

Every guide on MeshWorld is validated on physical Linux nodes and reproducible testbeds. If this article saved you hours of debugging or unblocked production, consider funding our next cluster run.

Weekly Dispatch

Join MeshWorld Dispatch

Get practical tutorials, system blueprints, and curated AI engineering notes straight to your inbox. No fluff, zero spam.

Zero spam. 1-click unsubscribe anytime.Prefer RSS?
Curated Continuations

Up Next in This Domain.

Browse Full Archive