Skip to content

PHP code snippet – 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
See also  Java code snippet - How to assert that an exception is thrown ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.