Here are some pointers:
) When doing algorithms with dates its good to use timestamps which you can build with the mktime() function.
) When looping over ranges of dates you may want to use a step of a particular unit of time. You can get such a unit by subtracting one time stamp from another:
$DAY = mktime(0,0,0,1,2,1970) - mktime(0,0,0,1,1,1970); // unit of one day
$start_day = mktime(0,0,0,8,1,2006);
$end_day = mktime(0,0,1,8,12,2006);
// iterate from start to end days stepping in units of one day:
for ($i = $start_day; $i < $end_day; $i += $DAY)
{
echo ("<p>" . strftime("%Y-%m-%d", $i) . "</p>\n");
}
*) You can use the range() function to create arrays of discrete timestamps (i.e., not continous):
$date_range = range($start_day, $end_day, $DAY);
echo("<p>\n");
var_dump($date_range);
echo("</p>\n");
*) You can use simple equality operators to work with date ranges as continuous sequences:
function date_in_range($date, $start, $end)
{
return (($date >= $start) && ($date <= $end));
}
Hope these thoughts provide some help.