Skip to content

Instantly share code, notes, and snippets.

@wintersun1993
Created August 20, 2014 18:32
Show Gist options
  • Save wintersun1993/52017b58b6714ab17ded to your computer and use it in GitHub Desktop.
Save wintersun1993/52017b58b6714ab17ded to your computer and use it in GitHub Desktop.
<?php
$dateOne=$_GET['dateOne'];
$dateTwo=$_GET['dateTwo'];
$holidays=$_GET['holidays'];
$holidayarr=preg_split('/[\s]+/', $holidays);
$string='';
$flag=false;
while (strtotime($dateOne) <= strtotime($dateTwo)) {
if(date('w', strtotime($dateOne)) != 0 &&date('w', strtotime($dateOne))!=6 && !in_array("$dateOne",$holidayarr) ) {
$string.="<li>".date('d',strtotime($dateOne)).'-'.date('m',strtotime($dateOne)).'-'.date('Y',strtotime($dateOne))."</li>";
$flag=true;
}
$dateOne = date ("d-m-Y", strtotime("+1 day", strtotime($dateOne)));
}
if($flag==true){
echo "<ol>$string</ol>";
}
else {
echo "No workdays";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment