Skip to content

Instantly share code, notes, and snippets.

@liuxd
Created April 26, 2018 23:46
Show Gist options
  • Select an option

  • Save liuxd/6e7684cd1357441732d46d4d3d61b2e4 to your computer and use it in GitHub Desktop.

Select an option

Save liuxd/6e7684cd1357441732d46d4d3d61b2e4 to your computer and use it in GitHub Desktop.
[addBusinessDays]
<?php
function addBusinessDays($startDate, $businessDays)
{
$date = strtotime($startDate . ' + 1 day');
$i = 0;
while($i < $businessDays)
{
//get number of week day (1-7)
$day = date('N', $date);
//get just Y-m-d date
$dateYmd = date("Y-m-d",$date);
if($day < 6){
$i++;
}
if ($i == $businessDays) {
return $dateYmd;
}
$date = strtotime($dateYmd . ' +1 day');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment