How7o
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Reading: How to Get Records Created Today in Laravel
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Web Development > How to Get Records Created Today in Laravel
Web Development

How to Get Records Created Today in Laravel

how7o
By how7o
Last updated: April 20, 2026
6 Min Read
Laravel Eloquent records today — Carbon today helper and whereDate illustration
SHARE

Pulling laravel eloquent records today — rows whose created_at falls within the current calendar day — is a single whereDate call once you know the shape. This guide shows the canonical one-liner, the older-Laravel variant that needs an explicit operator, a Carbon-free alternative using now()->toDateString(), and a high-precision whereBetween form that actually uses your index on large tables.

Contents
  • TL;DR
  • The canonical one-liner
  • The older-Laravel variant with explicit =
  • Without a Carbon import: now()->toDateString()
  • High-precision range with whereBetween
  • Timezone watch-outs
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-04-21 on Laravel 11 with PHP 8.3 and MySQL 8.0. Originally published 2022-10-07, rewritten and updated 2026-04-21.

TL;DR

Import Carbon and run Post::whereDate('created_at', Carbon::today())->get(). On older Laravel versions add the explicit operator: whereDate('created_at', '=', Carbon::today()). For large tables, use the index-friendly range form: Post::whereBetween('created_at', [today()->startOfDay(), today()->endOfDay()])->get().

The canonical one-liner

Drop this at the top of the file that uses it:

use Carbon\Carbon;

Then query:

$posts = Post::whereDate('created_at', Carbon::today())->get();

Eloquent’s whereDate scope compiles to DATE(created_at) = ?, and Carbon’s today() returns today’s date at 00:00:00, which Laravel serializes as Y-m-d for the bind. The resulting query returns every row created between today’s midnight and tomorrow’s midnight.

The older-Laravel variant with explicit =

If you’re maintaining a project pinned to an older Laravel minor, you may see a runtime error complaining that whereDate is missing its third argument. The fix is to pass the operator explicitly:

$posts = Post::whereDate('created_at', '=', Carbon::today())->get();

Modern Laravel (8.x and up) accepts the two-argument form and implies =, so the explicit operator is optional — but never wrong. If you’re unsure which minor you’re on, running with the explicit operator is the safe default.

laravel eloquent records today — whereDate vs whereBetween range on created_at

Without a Carbon import: now()->toDateString()

Laravel’s global now() helper returns a Carbon instance, so you can get today’s Y-m-d string without adding a use line:

$posts = Post::whereDate('created_at', now()->toDateString())->get();

now()->toDateString() returns '2026-04-21' (or whatever today is). The scope still compiles to DATE(created_at) = ?; the only difference is cosmetic — one less import line.

High-precision range with whereBetween

whereDate is convenient but wraps created_at in a SQL function, which prevents MySQL from using a B-tree index on that column. On tables with hundreds of thousands of rows, swap to a timestamp range that the optimizer can serve with an index scan:

$posts = Post::whereBetween('created_at', [
    today()->startOfDay(),
    today()->endOfDay(),
])->get();

today() is a Laravel helper equivalent to Carbon::today(). startOfDay() returns YYYY-MM-DD 00:00:00, endOfDay() returns YYYY-MM-DD 23:59:59, and the resulting SQL is created_at BETWEEN ? AND ? — a plain range predicate that benefits from an index.

Benchmark both on your data before committing; for small tables (<10k rows) the difference is imperceptible and whereDate is more readable.

Timezone watch-outs

“Today” is relative to a timezone. Laravel reads config/app.php‘s timezone and sets PHP’s default accordingly, so Carbon::today() respects the app timezone. MySQL’s TIMESTAMP columns, however, are normalized to UTC under the hood. If app timezone and DB timezone disagree, rows inserted around midnight can appear to “belong” to the wrong day.

Two clean options: keep config/app.php as 'UTC' and convert for display, or pass an explicit zone to Carbon — Carbon::today('Asia/Dhaka')->setTimezone('UTC') — so the bind value matches the stored column’s zone.

Frequently asked questions

How do I get laravel eloquent records today in one line?

Use whereDate against Carbon::today(): Post::whereDate('created_at', Carbon::today())->get(). Laravel compiles the scope to DATE(created_at) = ? and binds today’s Y-m-d string. Remember to use Carbon\Carbon; at the top of the file, or reach for now()->toDateString() instead.

Why do I get “whereDate missing argument 3” on older Laravel?

Some Laravel 5.x builds require the explicit operator for whereDate: Post::whereDate('created_at', '=', Carbon::today())->get(). The two-argument form landed later. If you’re on a modern (8.x+) release you can drop the '=' — the error is a signal that you’re on an older minor.

Can I avoid importing Carbon entirely?

Yes. Laravel’s global now() helper returns a Carbon instance, so Post::whereDate('created_at', now()->toDateString())->get() works with zero explicit imports. Under the hood it’s still Carbon, but you don’t need the use line.

Will whereDate use my created_at index?

Not cleanly. whereDate compiles to DATE(created_at) = ?, which wraps the column in a function and defeats a standard B-tree index on created_at. For high-traffic endpoints, switch to a range: Post::whereBetween('created_at', [today()->startOfDay(), today()->endOfDay()])->get(). It produces a plain BETWEEN clause that the optimizer can serve from an index.

What timezone does Carbon::today() use?

Carbon uses PHP’s default timezone, which Laravel sets from config/app.php‘s timezone key. If that’s 'UTC' but your created_at values are stored in local time (or vice versa), you’ll see rows appear to slip across the day boundary. Either keep both sides UTC or pass a zone-aware constructor: Carbon::today('Asia/Dhaka').

Related guides

  • How to Install Laravel on Ubuntu — bootstrap the Laravel 11 environment.
  • How to Get Current Month Records in Laravel Eloquent — the month-scope counterpart.
  • How to Count Rows in Laravel Eloquent — combine today’s filter with a count.
  • How to Check if a Record Exists in Laravel — the lightweight existence check.

References

Official Laravel query builder docs (whereDate, whereBetween): laravel.com/docs/queries.

TAGGED:EloquentLaravelmysqlphp

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Laravel Eloquent current month records — calendar and query builder illustration How to Get Current Month Records in Laravel Eloquent
Next Article Laravel last inserted ID — Eloquent save populates model primary key illustration How to Retrieve the Last Inserted ID in Laravel Eloquent
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
Laravel left outer join — query builder leftJoin illustration with two tables
How to Do a Left Outer Join in Laravel Query Builder
April 20, 2026
Laravel last inserted ID — Eloquent save populates model primary key illustration
How to Retrieve the Last Inserted ID in Laravel Eloquent
April 20, 2026
Laravel Eloquent records today — Carbon today helper and whereDate illustration
How to Get Records Created Today in Laravel
April 20, 2026
Laravel Eloquent current month records — calendar and query builder illustration
How to Get Current Month Records in Laravel Eloquent
April 20, 2026
Laravel Eloquent group by count — Book::groupBy('author') query with bar-chart aggregate icon
How to Count Records Grouped By a Column in Laravel Eloquent
April 20, 2026

You Might Also Like

Laravel foreign key constraint linking posts.user_id to users.id in a schema diagram
Web Development

How to Add Foreign Keys in Laravel Migration

6 Min Read
Login to Laravel programmatically without a password (Auth::login and loginUsingId)
Web Development

Login to Laravel Programmatically Without a Password (Auth::login & loginUsingId)

4 Min Read
Laravel Eloquent orderBy — code snippet sorting posts by id descending with arrow icons
Web Development

How to Use orderBy in Laravel Eloquent (with Examples)

6 Min Read
Laravel migration adding two new columns to an existing transactions table
Web Development

How to Add New Columns to an Existing Table in Laravel Migration

5 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?