Created
April 26, 2018 23:46
-
-
Save liuxd/6e7684cd1357441732d46d4d3d61b2e4 to your computer and use it in GitHub Desktop.
[addBusinessDays]
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 | |
| 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