Answers for "carbon get week number from date"

0

carbon get total week of the month

Route::get('/enter_month_num/{month}',function($month){
    $year = Carbon::now()->year;
    $date = Carbon::createFromDate($year,$month);
    $numberOfWeeks = floor($date->daysInMonth / Carbon::DAYS_PER_WEEK);
    $start = [];
    $end = [];
    $j=1;
    for ($i=1; $i <= $date->daysInMonth ; $i++) {
        Carbon::createFromDate($year,$month,$i); 
        $start['Week: '.$j.' Start Date']= (array)Carbon::createFromDate($year,$month,$i)->startOfWeek()->toDateString();
        $end['Week: '.$j.' End Date']= (array)Carbon::createFromDate($year,$month,$i)->endOfweek()->toDateString();
        $i+=7;
        $j++; 
    }
    $result = array_merge($start,$end);
    $result['numberOfWeeks'] = ["$numberOfWeeks"];
    return $result;
});
Posted by: Guest on June-21-2021
-1

carbon get week number from date

carbon get week from month
Posted by: Guest on July-01-2021

Code answers related to "carbon get week number from date"

Browse Popular Code Answers by Language