Hi, here I included my code to find no of working days between two years.
But in leap year I do not know how to find the working days.
Can anyone help me?
function calculate($month,$year)
{
$Start_Date="1/".$month."/".$year."";
$myTime = strtotime($Start_Date); // Use whatever date format you want
$daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year); // 31
//$workDays = 0;
while($daysInMonth > 0)
{
$day = date("D", $myTime); // Sun - Sat
if($day != "Sun" && $day != "Sat")
$workDays++;
$daysInMonth--;
$myTime += 86400; // 86,400 seconds = 24 hrs.
}
return $workDays;
}
<?php echo calculate($MONTH,$YEAR)?>
AntonyRayan 15 Posting Whiz in Training
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.