Skip to content

Instantly share code, notes, and snippets.

@EduardoSP6
Created July 12, 2018 19:02
Show Gist options
  • Save EduardoSP6/4d85fdba3ae19b052ab747dddf4491d4 to your computer and use it in GitHub Desktop.
Save EduardoSP6/4d85fdba3ae19b052ab747dddf4491d4 to your computer and use it in GitHub Desktop.
PHP function to skip weekend days with Carbon
public function skipWeekend($dt) {
if ($dt->isWeekend()) {
$dw = $dt->dayOfWeek;
if ($dw == 6) {
return $dt->addDay(2);
} else if ($dw == 0) {
return $dt->addDay();
}
}
return $dt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment