Get current month records in laravel 7/8

Updated at 20-May-2021, By samar

Get current month records in laravel 7/8

Hello everyone, in this post we will look at how to solve "Get current month records in laravel 7/8" in programming.

You can get the current month records in laravel with where condition on the current year and current month. Laravel provides whereYear() and whereMonth() conditions to get the current month records in the query builder.
  • Get current month records from table in laravel 8

    $users = \DB::table('users')
                 ->whereYear('created_at', \Carbon\Carbon::now()->year)
                 ->whereMonth('created_at', \Carbon\Carbon::now()->month)
                 ->get();
    dd($users);
    

Back to code snippet queries related laravel