This is the function I\'m trying to write:
function getWednesdays($month, $year) {
// Returns an array of DateTimes representing all Wednesdays this month
I have re-written @Gordon's solution to suit for any day
function get_dates_of_day($y, $m, $day_name)
{
return new DatePeriod(
new DateTime("first $day_name of $y-$m"),
DateInterval::createFromDateString("next $day_name"),
new DateTime("next month $y-$m-01")
);
}
Now you can simply do get_dates_of_day('2015','08','wednesday')
and use the same to get dates for any day in a given month.