Revision: 32118
Updated Code
at September 21, 2010 15:26 by aamirrajpoot
Updated Code
/**
* Get working days between two dates, with custom off day
*
* @param Date $startDate End Date
* @param Date $endDate To date
* @param Array $holidays Week Number in Single dimension array
* @return integer
*/
function getWorkingDays_customOffDay($startDate, $endDate, $holidays) {
$day = 86400; // Day in seconds
$sTime = strtotime($startDate); // Start as time
$eTime = strtotime($endDate); // End as time
$numDays = round(($eTime - $sTime) / $day) + 1;
$days = array();
for ($d = 0; $d < $numDays; $d++) {
$day_number = date('N', ($sTime + ($d * $day)));
if (!in_array($day_number, $holidays)) {
$days[] = date('Y-m-d N', ($sTime + ($d * $day)));
}
}
return count($days);
}
Revision: 32117
Updated Code
at September 18, 2010 20:44 by aamirrajpoot
Updated Code
/**
* Get working days between two dates, with custom off day
*
* @param Date $startDate End Date
* @param Date $endDate To date
* @param integer $holidays Week Number in Single dimension array
* @return integer
*/
function getWorkingDays_customOffDay($startDate, $endDate, $holidays) {
$day = 86400; // Day in seconds
$format = ''; // Output format (see PHP date funciton)
$sTime = strtotime($startDate); // Start as time
$eTime = strtotime($endDate); // End as time
$numDays = round(($eTime - $sTime) / $day) + 1;
$days = array();
for ($d = 0; $d < $numDays; $d++) {
$day_number = date('N', ($sTime + ($d * $day)));
if (!in_array($day_number, $holidays)) {
$days[] = date('Y-m-d N', ($sTime + ($d * $day)));
}
}
return count($days);
}
Revision: 32116
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 18, 2010 20:38 by aamirrajpoot
Initial Code
/**
* Get working days between two dates, with custom off day
*
* @param Date $startDate End Date
* @param Date $endDate To date
* @param integer $holidays Week Number in Single dimension array
* @return integer
*/
function getWorkingDays_customOffDay($startDate, $endDate, $holidays) {
$day = 86400; // Day in seconds
$format = ''; // Output format (see PHP date funciton)
$sTime = strtotime($startDate); // Start as time
$eTime = strtotime($endDate); // End as time
$numDays = round(($eTime - $sTime) / $day) + 1;
$days = array();
for ($d = 0; $d < $numDays; $d++) {
$day_number = date('N', ($sTime + ($d * $day)));
if (!in_array($day_number, $holidays)) {
$days[] = date('Y-m-d N', ($sTime + ($d * $day)));
}
}
return count($days);
}
Initial URL
Initial Description
Initial Title
Get working days between two dates, with custom off day
Initial Tags
date
Initial Language
PHP