This is the function I\'m trying to write:
function getWednesdays($month, $year) {
// Returns an array of DateTimes representing all Wednesdays this month
Try This one to get all Wednesdays in current month.
$month = date('m');
$year = date('Y');
function getDays($year,$month){
$days = cal_days_in_month(CAL_GREGORIAN, $month,$year);
$wed = array();
for($i = 1; $i<= $days; $i++){
$day = date('Y-m-'.$i);
$result = date("D", strtotime($day));
if($result == "Wed"){
$wed[] = date("Y-m-d", strtotime($day)). " ".$result."
";
}
}
return $wed;
}
$wed = getDays($year,$month);
print_r($wed);