DEV Community

Vishnu Damwala
Vishnu Damwala

Posted on โ€ข Originally published at meshworld.in

4 1

Laravel's Eloquent whereTime() filtering method

Laravel provides many additional methods other than standard methods. You might be familiar with where(), orWhere(), whereJsonContains() or whereJsonLength(). And these additional methods are worth checking.

In this article, we will see whereTime(), one of the supplementary methods that comes in handy when you want to compare the table's field value with a specific time.

whereTime()

The whereTime() method helps to get records matching the specific time.

Sytnax

whereTime('fieldName', 'operator', 'time');
Enter fullscreen mode Exit fullscreen mode
  • The first parameter is fieldName with which a comparison is to be done.
  • The second parameter is an operator for comparison, such as =, <>, >, >=, < or <=.
  • The third parameter is a time for comparison in HH:MM:SS.

Example

$users = User::whereTime('login_at', '11:12:31')->get();
Enter fullscreen mode Exit fullscreen mode

Read the complete post on our site Laravel's whereTime Model Method

Read others post on our site MeshWorld

Happy ๐Ÿ˜„ coding

With โค๏ธ from ๐Ÿ‡ฎ๐Ÿ‡ณ

Sentry image

See why 4M developers consider Sentry, โ€œnot bad.โ€

Fixing code doesnโ€™t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay