Last active
January 8, 2025 20:21
-
-
Save EduardoSP6/4d85fdba3ae19b052ab747dddf4491d4 to your computer and use it in GitHub Desktop.
PHP function to skip weekend days with Carbon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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