Get current month records in laravel 7/8

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.

Answers 1
  • 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);
    
    0
  • Back to code snippet queries related laravel