ItSolutionStuff.com

How to Get Today Created Records in Laravel?

By Hardik Savani • April 16, 2024
Laravel

This simple article demonstrates of how to get today data in laravel. I’m going to show you about how to get current date in laravel controller. We will look at example of laravel get today records. i explained simply about laravel get records created today. You just need to some step to done how to get records created today in laravel.

we can get today created records in laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 application.

Here, i will give you very simple example of how to get today data in laravel. we will use whereDate() and Carbon Object for date in this example.

I have one created items table that structure as bellow you can see.

items table

Controller Code:

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Http;

use App\Models\Item;

use Carbon\Carbon;

class ITSController extends Controller

{

/**

* Write code on Method

*

* @return response()

*/

public function index()

{

$items = Item::select("*")

->whereDate('created_at', Carbon::today())

->get();

dd($items);

}

}

Output:

Array

(

[0] => Array

(

[id] => 9

[title] => Dr.

[body] => Body 4

[created_at] => 2021-10-06T18:13:40.000000Z

[updated_at] => 2021-08-12T13:46:08.000000Z

)

)

I hope it can help you...

Tags: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

šŸ“ŗ Subscribe on YouTube

We Are Recommending You

ā˜…

Laravel Get Next and Previous Record with URL Example

Read Now →
ā˜…

How to Restore Deleted Records in Laravel?

Read Now →
ā˜…

Laravel Copy Record using Eloquent Replicate Example

Read Now →
ā˜…

How to Get Last 7 Days Record in Laravel?

Read Now →
ā˜…

How to Get Last 30 Days Record in Laravel?

Read Now →
ā˜…

Laravel Eloquent Delete Record By ID Example

Read Now →
ā˜…

Delete All Records from Table in Laravel Eloquent

Read Now →
ā˜…

How to Get Last Record from Database in Laravel?

Read Now →
ā˜…

How to Get Soft Deleted Records in Laravel?

Read Now →
ā˜…

How to Insert Multiple Records in Laravel?

Read Now →
ā˜…

How to Check If Record Exists or Not in Laravel?

Read Now →