Skip to content

Instantly share code, notes, and snippets.

@samwx
Last active December 22, 2015 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samwx/6546274 to your computer and use it in GitHub Desktop.
Save samwx/6546274 to your computer and use it in GitHub Desktop.
Function for sum weekends between two dates
<?php
function sumWeekends($start, $end) {
$start_date = strtotime($start);
$end_date = strtotime($end);
$n = floor(($end_date - $start_date) / 86400);
$n_weekends = ceil($n/7);
if (date("N", $start_date) == 6 && $n%7 == 0 ){
$n_weekends++;
}
return $n_weekends;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment