Php - Get week dates of current month, Fetch current week days

Get week dates of current month

 $year=date("Y");
 $month=date('m');
 $datee=strtotime("$curr_yea-$curr_mon");
 $cur_end=date("Y-m-d",strtotime("+1 month -1 second",$datee));//date("Y-m-t", strtotime("-1 now") ) ;
 $end = new DateTime("$cur_end");
 $endTimestamp = $end->getTimestamp();
 $now = new DateTime("$curr_yea-$curr_mon-01");
 $now->setTime(0,0);
 if (($now->format("l") == "Saturday") || ($now->format("l") == "Sunday"))
 $d = $now;
 else
 $d = $now;
 
 $oneday = new DateInterval("P1D");
 $sixdays = new DateInterval("P6D");
 $res = array();
 
 while ($d->getTimestamp() <= $endTimestamp) {
 $res[] = $d->format("Y-m-d");
 $d = $d->add($oneday);
 if ($d->getTimestamp() <= $endTimestamp) {
 $res[] = $d->format("Y-m-d");
 }
 $d = $d->add($sixdays);

 }
 print_r($res);

The topic on Php - Get week dates of current month is posted by - Maha

Hope you have enjoyed, Php - Get week dates of current monthThanks for your time

Tech Bluff