I found this function in the list archives while searching on how to find the number of a weekday (say, Tuesdays) between 2 dates..
function weekdaysBetween ($timestamp1, $timestamp2, $weekday) { return floor(intval(($timestamp2 - $timestamp1) / 86400) / 7) + ((date('w', $timestamp1) <= $weekday) ? 1 : 0); } Sometimes it works, but I've come across a date while testing this that doesn't work, which makes me think there is some bug in the function that I'm not seeing. The 2 dates I am trying are: 01-04-2002 and 02-05-2002 There should be 5 Tuesdays: 01-08-2002 01-15-2002 01-22-2002 01-29-2002 02-05-2002 Yet the script only returns 4, leaving off 02-05-2002. $nowdate = mktime(0, 0, 0, $STARTMONTH, $STARTDAY, $STARTYEAR); $futuredate = mktime(0, 0, 0, $ENDMONTH, $ENDDAY, $ENDYEAR); That's how I'm generating the time stamps to pass to the function, and I've confirmed the dates I've entered are correct.. echo weekdaysBetween($nowdate, $futuredate, 2); Returns 4 .. can anyone assist? Thanks, Chad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php