Site Admin
Site Admin Founder of MeaningArticles
1269 Views

Laravel get today Date Record

Hello Dev.

In this example,i can learn you the way to get today date data in laravel. you may surely get to cutting-date records in laravel.

I provide you with simple and easy example of get today date record in laravel. you can see bellow example in whereDate function is used.

So let's start the lesson...

 

Example 1:

/** 
* The attributes that are mass assignable. 
* 
* @var array 
*/ 
public function data(Request $request) 
{ 
    $users = User::whereDate('created_at', Carbon::today())->get(); 
 
    dd($users); 
}

 

Example 2:

/** 
* The attributes that are mass assignable. 
* 
* @var array 
*/ 
public function data(Request $request) 
{ 
    $users = DB::table('users')->select(DB::raw('*')) 
              ->whereRaw('Date(created_at) = CURDATE()')->get(); 
 
    dd($users); 
}

I hope it assists you, thanks for visiting my article if you like my article then share it with your friends on the social media platform.

Happy Coding.....