Get Working Days between 2 dates with PHP
We needed to work out the working days between two dates for a small calendar application we had to write. After looking round the net for a few minuets we decided to write a quick function for ourself.
It takes 3 inputs. A From Date (Epoch) , a To Date (Epoch) and an array with Bank Holiday dates in it. By the time it has finished it has a variable $WorkingDays with the number of working days in the give range.
The main logic goes like this
while ( $StartTime <= $EndTime ) {
if (
date(”D”,$StartTime) == “Sat” ||
date(”D”,$StartTime) == “Sun” ||
array_key_exists(date(”Ymd”,$StartTime),$BankHolidays) ) {
$IgnorDays++;
} else {
$WorkingDays++;
}
$StartTime=$StartTime+86400;
}
July 21st, 2010 at 7:07 am
Buy:Nymphomax.Lipothin.Aricept.Benicar.Ventolin.Amoxicillin.SleepWell.Advair.Acomplia.Female Pink Viagra.Buspar.Zocor.Lasix.Wellbutrin SR.Cozaar.Female Cialis.Zetia.Seroquel.Prozac.Lipitor….