Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $date = date('Y-m-01'); $year = date('Y'); $month = date('m'); $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; $shift = 8-$day_of_week; return date('Y-m-d', strtotime("+{$shift} day", strtotime($date))); } else { echo "Work day ($day_of_week):" . $date . PHP_EOL; return date('Y-m-d', strtotime('+3 day', strtotime($date))); } } function isWeekend($date) { return (date('N', strtotime($date)) >= 6); } function isWorkDay($num) { return ($num % 4) < 2; } while ($date < $next_month) { $date = nextWorkDay($date); //die($date); }
Copy Clear