HI,
I want to calculate number of working days for the academic year between two dates like(01-06-2015 to 31-10-2015).
I saw all codes that are doing only for curtrent year.
If I want to do future years , how to do automatically,
Here is my code what I tried , It works for only one year, I need to calculate dynamically for future years
$beginday = date("Y-m-01");
$lastday = date("Y-m-t");
$nr_work_days = getWorkingDays($beginday, $lastday);
echo $nr_work_days;
function getWorkingDays($startDate, $endDate)
{
$begin = strtotime($startDate);
$end = strtotime($endDate);
if ($begin > $end) {
echo "startdate is in the future! <br />";
return 0;
} else {
$no_days = 0;
$weekends = 0;
while ($begin <= $end) {
$no_days++; // no of days in the given interval
$what_day = date("N", $begin);
if ($what_day > 5) { // 6 and 7 are weekend days
$weekends++;
};
$begin += 86400; // +1 day
};
$working_days = $no_days - $weekends;
return $working_days;
}
}
AntonyRayan 15 Posting Whiz in Training
diafol
AntonyRayan 15 Posting Whiz in Training
AntonyRayan 15 Posting Whiz in Training
diafol
AntonyRayan 15 Posting Whiz in Training
diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.