Created
January 11, 2012 10:36
-
-
Save tamewhale/1594092 to your computer and use it in GitHub Desktop.
Revisions
-
tamewhale revised this gist
Feb 11, 2013 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,18 @@ <?php // accepts a DateTime object which is now by default // and returns a DateTime object x working days from now // where x defaults to 1 function get_next_working_day($date = new DateTime, $no_of_days = 1) { // add the number of days passed but skip weekends for ($i = 0; $i < $no_of_days; $i++) { do { $date::add(new DateInterval('P1D')); } while (in_array($date->format('D'), array('Sat', 'Sun'))); // keep adding if day is a Saturday or Sunday } return $date; } -
tamewhale created this gist
Jan 11, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ <?php function get_next_working_day($timestamp, $no_of_days = 1) { // add the number of days passed but skip weekends for ($i = 0; $i < $no_of_days; $i++) { do { $timestamp = strtotime('+1 day', $timestamp); } while (in_array(date('D', $timestamp), array('Sat', 'Sun'))); // keep adding if day is a Saturday or Sunday } return $timestamp; }