tags:

views:

61

answers:

2
A: 

date('N', $theDate) gives you the day of the week (6 for Saturday and 7 for Sunday). From there, you can easily implement a function that does only counts workdays. On the other hand, this does not detect holidays.

Victor Nicollet
thDate needs to be a unix timestamp for that.
RobertPitt
You're right. I always assume dates to be in timestamp format ;) the conversion from YYYY/MM/DD can be made with strtotime()
Victor Nicollet
+2  A: 

Quick iteration:

$days = 0;
for($i = time(); $i < (strtotime('29.07.2010') + 86400); $i=$i+86400)
{
    $weekday = date('w', $i);
    if($weekday > 0 &&  $weekday < 6)
    {
       $days++; 
    }
}

echo $days;
narcisradu
That was quick. Thanks to all.
Faili
You are welcome. I found that piece of code once and I saved it into my library. Anyway, I will never use it, since there are better ways to do it. Just take a look at http://stackoverflow.com/questions/336127/calculate-business-days for a much better approach.
narcisradu
hmm, would that have failed on December 31st, 2008. 23:59:60? (Yes, it existed). That time + 86400 would have been January 2nd. An edge case if I ever saw one, nonetheless...
Wrikken
@Wrikken - interesting. Anyway, your edge case is somehow strange and the probability to replicate is extremely rare.
narcisradu