Skip to content

Instantly share code, notes, and snippets.

@ademalp
Created October 25, 2017 15:24
Show Gist options
  • Save ademalp/149d53a23b3e407351bf39aaf78c76fb to your computer and use it in GitHub Desktop.
Save ademalp/149d53a23b3e407351bf39aaf78c76fb to your computer and use it in GitHub Desktop.
<?php
//return[0] sunday/pazar
function dayCount($start,$end){
$time = strtotime($start);
$end = strtotime($end);
$days = array();
$day = date("w",$time);
isset($days[$day])?$days[$day]++ :$days[$day]=1;
while($time < $end){
$time = strtotime("+1 day",$time);
$day = date("w",$time);
isset($days[$day])?$days[$day]++ :$days[$day]=1;
}
ksort($days);
return $days;
}
var_export(dayCount("2017-11-01","2017-11-30"));
array (
0 => 4,
1 => 4,
2 => 4,
3 => 5,
4 => 5,
5 => 4,
6 => 4,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment