Get current month records in laravel 7/8

Created 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

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.