Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $from = $_GET['dateOne'];
- $to = $_GET['dateTwo'];
- $holidays = preg_split("/\s+/", $_GET['holidays'], -1, PREG_SPLIT_NO_EMPTY);
- //$from = '17-12-2014';
- //$to = '31-12-2014';
- //$holidays = array('31-12-2014', '24-12-2014', '08-12-2014');
- $workdays = array();
- for ($currDate = date("d-m-Y", strtotime($from)); $currDate < date("d-m-Y", strtotime($to)); $currDate = date("d-m-Y", strtotime($currDate . ' + 1 days'))) {
- if (date('N', strtotime($currDate)) != 6 && date('N', strtotime($currDate)) != 7) {
- foreach ($holidays as $holiday) {
- if (date('d-m-Y', strtotime($currDate)) != date('d-m-Y', strtotime($holiday))) {
- $workdays[] = date('d-m-Y', strtotime($currDate));
- }
- }
- }
- }
- echo '<ol>' . "\n";
- foreach (array_unique($workdays) as $day) {
- echo '<li>' . $day . '</li>' . "\n";
- }
- echo '</ol>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement