Skip to content

Instantly share code, notes, and snippets.

@MasterEx
Created January 23, 2012 12:57
Show Gist options
  • Save MasterEx/1663006 to your computer and use it in GitHub Desktop.
Save MasterEx/1663006 to your computer and use it in GitHub Desktop.
<?php
function getDays($start,$end,$day) {
$days = array();
$now = strtotime("first $day $start");
$stop = strtotime("last $day $end");
while($now <= $stop) {
$days[] = $now;
$now = strtotime("next $day",$now);
}
return $days;
}
foreach (getDays('2012-01-05','2012-02-06','Sunday') as $sunday) {
echo date('Y-m-d',$sunday).' ';
}
?>
2012-01-08 2012-01-15 2012-01-22 2012-01-29 2012-02-05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment