Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_GET['dateOne'])&&isset($_GET['dateTwo'])&&isset($_GET['holidays'])) {
- $dateStart = new DateTime($_GET['dateOne']);
- $dateEnd = new DateTime($_GET['dateTwo']);
- $dateEnd->modify('+1 day');
- $arr = explode("\n",$_GET['holidays']);
- foreach ($arr as $row) {
- if ($row!='') {
- $holidays[]=new DateTime($row);
- }
- }
- $diff=$dateStart->diff($dateEnd);
- while ($diff->d>0) {
- $isHoliday=false;
- if (isset($holidays)) {
- foreach ($holidays as $holiday) {
- if ($holiday->format('d-m-Y')==$dateStart->format('d-m-Y')) {
- $isHoliday=true;
- }
- }
- }
- if (date('l',$dateStart->getTimestamp())!='Sunday'&&date('l',$dateStart->getTimestamp())!='Saturday'&&!$isHoliday) {
- $workingDates[]=$dateStart->format('d-m-Y');
- }
- $dateStart->modify('+1 day');
- $diff=$dateStart->diff($dateEnd);
- }
- if (isset($workingDates)) {
- echo '<ol>';
- foreach ($workingDates as $workingDate) {
- echo "<li>$workingDate</li>";
- }
- echo '</ol>';
- } else {
- echo '<h2>No workdays</h2>';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement