Possible Duplicate:
Calculate business days
I have a report that shows project schedules and in that report I have a semaphore that changes with the difference between the project planned start date and the real that, ie:
If the planned date is the same as the real start date, the semaphore is green.
If the difference in days between dates is > 0 and < 2, then its yellow.
If the difference is > 3 the semaphore is in red.
My code looks like this:
if( (strtotime($real) - strtotime($planned)) == 0 )
{
$semaphore = 'green';
}
The problem is when the planned date is for example on friday, and the project started really on next monday. In this case the semaphore should be yellow as the project started one (working) day later than planned. The problem is I'm counting saturday and sunday, and the semaphore shows in red.
How can I make this exception?
EDIT:
I finally end up doing this:
if((date('l',strtotime($planned)) == 'Friday') AND (strtotime('next monday',strtotime($planned)) == strtotime($real)))
{
$semaphore = 'yellow';
}