- date: documentation ( source)
- strtotime: documentation ( source)
<?php
function getWednesdays($y, $m)
{
$ts = strtotime("first wednesday $y-$m-01");
$end = strtotime("last wednesday $y-$m");
$wednesdays = array();
while($ts <= $end) {
$wednesdays[] = $ts;
$ts = strtotime('next wednesday', $ts);
}
return $wednesdays;
}
foreach (getWednesdays(2014, 1) as $wednesday) {
echo date("l, Y-m-d\n", $wednesday);
}