Welcome Guest, Not a member yet? Register   Sign In
Add X days to current date and calculate excluding saturdays and sundays
#6

[eluser]ninjayan[/eluser]
Thank you. I appreciate your effort. I also found this code but not so sure thou.

Code:
$startDate = date("M d, Y");// current date
$endDate = $startDate;
$numDays = 10;
$counter = 1;
while ($counter <= $numDays) {

   $endDate = date("M d, Y", strtotime(date("Y-m-d", strtotime($endDate)) . " +1 day"));
   $dayOfTheWeek = date("l",strtotime($endDate));

if ($dayOfTheWeek == "Saturday" || $dayOfTheWeek == "Sunday") {
       continue;
   }else {
      $counter++;
   }

}

echo "startDate: $startDate<br />";
echo "endDate: $endDate<br />";

Your code also answered my problem. thanks again.


Messages In This Thread
Add X days to current date and calculate excluding saturdays and sundays - by El Forum - 10-18-2012, 12:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB