-
-
Save brpaz/090a9c369b1cc4716740 to your computer and use it in GitHub Desktop.
Add business days to a DateTime #php #date #businessdays
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
public function add_business_days($datetime, $duedays) | |
{ | |
$i = 1; | |
while ($i <= $duedays) | |
{ | |
$next_day = date('N', strtotime('+1 day', $datetime)); | |
if ($next_day == 6 || $next_day == 7) | |
{ | |
$datetime = strtotime('+1 day', $datetime); | |
continue; | |
} | |
$datetime = strtotime('+1 day', $datetime); | |
$i++; | |
} | |
return $datetime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment