how to find two date under how many mondays find in laravel corban code example

Example: how to find two date under how many mondays find in laravel corban

// its wrong methods 
$dateDay = \Carbon\Carbon::now();//use your date to get month and year
$now = Carbon::now(); // current date
$end = Carbon::parse("2020-11-22"); //insert date
$length = $end->diffInDays($now); //total days
$resultDays = array('Monday' => 0,'Tuesday' => 0,'Wednesday' => 0,'Thursday' => 0,'Friday' => 0,'Saturday' => 0,'Sunday' => 0);
// dd($end);
foreach($days as $key => $value)
{
  dd($value);

}
while($now <= $end)
{
  if($now->englishDayOfWeek == "Friday")
  {
    dd("dsfs");
  }

}
$year = $dateDay->year;
$month = $dateDay->month;
$days = $dateDay->daysInMonth;
$mondays=[];
foreach (range(1, $days) as $day) {
  $date = \Carbon\Carbon::createFromDate($year, $month, $day);
  if ($date->isMonday()===true) {
    $mondays[]=($date->day);
  }

}
dd($mondays);
//@sujay

Tags:

Misc Example