Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get current month records in laravel

//get week
$current_week = User::whereBetween('created_at', [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()])->get();
// month
$current_month = User::whereBetween('created_at', [Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth()])->get();
// quarter
$current_quarter = User::whereBetween('created_at', [Carbon::now()->startOfQuarter(), Carbon::now()->endOfQuarter()])->get();
// year
$current_year = User::whereBetween('created_at', [Carbon::now()->startOfYear(), Carbon::now()->endOfYear()])->get();
 
PREVIOUS NEXT
Tagged: #current #month #records #laravel
ADD COMMENT
Topic
Name
6+5 =