PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $date = date('Y-m-01'); $next_month = date('Y-m-d', strtotime('+1 month', strtotime($date))); function nextWorkDay($date) { $day_of_week = date('N', strtotime($date)); if ($day_of_week>5) { echo "Weekend:" . $date . PHP_EOL; if ($day_of_week == 7) { echo "Weekend:" . date('Y-m-d', strtotime('+1 day', strtotime($date))) . PHP_EOL; } $shift = 8-$day_of_week; return date('Y-m-d', strtotime("+{$shift} day", strtotime($date))); } else { echo "Work day:" . $date . PHP_EOL; echo "No work day:" . date('Y-m-d', strtotime('+1 day', strtotime($date))) . PHP_EOL; echo "No work day:" . date('Y-m-d', strtotime('+2 day', strtotime($date))) . PHP_EOL; return date('Y-m-d', strtotime('+3 day', strtotime($date))); } } while ($date < $next_month) { $date = nextWorkDay($date); }
Show:  
Copy Clear