Eloquent whereMonth Query Use in Laravel

whereMonth Query Use in Laravel 5.8, whereMonth Query Use in Laravel 5.7, whereMonth Query Use in Laravel 5.6, whereMonth Query Use in Laravel 5.5, whereMonth Query Use in Laravel 5.4, whereMonth Query Use in Laravel 5.3, whereMonth Query Use in Laravel 5.2

 

Hello Friends Today I will tell you through tutorials that whereMonth query is used in the laravel framework.

The whereMonth method may be used to compare a column’s value against a specific month of a year.

$month = '10';
$blog = DB::table('blogs')
->whereMonth('created_at', $month)
->get();

By creating a model of your table, this query can be written in this way

$month = '10';
$blog = Blog::whereMonth('created_at', $month)->get();