Hi
I think this works :)

<?
$date1 = "1/1/2002";
$date2 = date("m/d/Y");
$time1 = strtotime($date1);
$time2 = strtotime($date2);
//get the first monday after date1
$first_monday = strtotime("first monday",$time1);
//check if its within date2
if($first_monday < $time2):
         //set count to 0 as we will go through the loop at least once
         $mondays = 0;
         $next_monday = $first_monday;
         //keep adding 7 days till we pass date2
         while($next_monday < $time2):
                 $next_monday = strtotime("+7 days",$next_monday);
                 $mondays ++;
         endwhile;
         echo "There are $mondays Mondays between $date1 and $date2 and the 
following monday is on ".date("m/d/Y",$next_monday)."<br>";
else:
         echo "there are no Mondays between $date1 and $date2 <br>";
endif;
?>
Tom



At 10:22 AM 19/05/2002, Josh Edwards wrote:
>Does anyone know  a good way to count the days between two dates. ie how
>many Mondays fall between two dates. As a starting  point I have calculated
>the start and end dates and the no of days b/w them.
>
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to