Skip to content

Instantly share code, notes, and snippets.

@brpaz
Forked from davidsalazar/Add business days.php
Last active October 9, 2023 20:31
Show Gist options
  • Save brpaz/090a9c369b1cc4716740 to your computer and use it in GitHub Desktop.
Save brpaz/090a9c369b1cc4716740 to your computer and use it in GitHub Desktop.
Add business days to a DateTime #php #date #businessdays
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