On Sun, 19 May 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.

Pretty much common sense, right? How about something like this:

  // $timestamp1 = starting date (unix timestamp)
  // $timestamp2 = ending date (unix timestamp)
  // $weekday = day we're counting (0 = Sunday, 1 = Monday, etc.)
  function weekdaysBetween ($timestamp1, $timestamp2, $weekday)
  {
    return floor(intval(($timestamp2 - $timestamp1) / 86400) / 7)
      + ((date('w', $timestamp1) <= $weekday) ? 1 : 0);
  }

miguel


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

Reply via email to