M
MeshWorld.
Laravel Eloquent PHP Database 5 min read

Laravel Eloquent whereTime() Method Explained

Vishnu
By Vishnu
| Updated: Mar 27, 2026

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.

:::note[TL;DR]

  • whereTime('column', 'HH:MM:SS') matches records where the time part equals the given time
  • Ignores the date — records from any day match if the time fits
  • Supports all six comparison operators: =, <>, >, >=, <, <=
  • Time format must be HH:MM:SS (24-hour clock)
  • Combine two whereTime() calls to filter a time window :::

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 =.

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:

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

Records created after 5pm:

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

Records created before noon:

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

Records NOT created at midnight:

$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):

$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:

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:

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

:::warning Like whereDate(), whereTime() wraps the column in TIME(), which prevents index usage on that column. On large tables, this causes a full table scan. For high-volume queries, a raw BETWEEN on the full datetime column — combined with a composite index — will perform significantly better. :::

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:30pm, 09:00:00 for 9am. There’s no AM/PM variant.

Can I pass only hours and minutes — like ‘18:30’ instead of ‘18:30:00’? 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.