Get last year created records in Laravel

Created at 18-Nov-2021 , By samar

Get last year created records in Laravel

In this article, we will see how to solve "Get last year created records in Laravel".

You can get the last year created records in Laravel. You can use whereYear() method which will help you to get the previous year records from database table.
  • Get last year created records in Laravel

    App\Models\User::whereYear('created_at', date('Y', strtotime('-1 year')))->get();
    

    You can get last year records in Laravel using whereYear() method. This code snippet will return all the user records from users table which are created at previous year.

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.