note 40711 deleted from function.date by kennyt

From: Date: Sun, 18 Jul 2004 17:23:31 +0000
Subject: note 40711 deleted from function.date by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73505@lists.php.net to get a copy of this message
Note Submitter: mike@gorillasoft.com ---- For those of you looking for something like this... This will help you solve for the number of business days between two given days. It will return a negative value if the days are reversed. function business_days( $startDay, $endDay ) ############### # Written by Mike Whitman <mike@gorillasoft.com> # # Function: formDisable() # Description: # This function calculates the number of business days between to days. # Parameters: # $startDay timestamp(double format) # $endDay timestamp(double format) # History: # ------------------------- # Editor: Change: Date: # ---------------------- # Mike Whitman Created 12/20/2002 ################# { if ( $startDay < $endDay ) { $theStart = $startDay; $theEnd = $endDay; } else { $theStart = $startDay; $theEnd = $endDay; } $daysDiff = ceil(($theEnd - $theStart)/(60*60*24)); $weeksDiff = floor($daysDiff)/7); $businessDays = 5*$weeksDiff; $extraDays = $daysDiff - ($weeksDiff*7); while ( $extraDays ) { switch ( date('w',$theEnd) ) { case 0: break; case 6: break; default: $businessDays++; break; } $theEnd -= (60*60*24); $extraDays--; } return $businessDays; } Thanks to all of those who contribute, I hope this helps someone. -M

« previous php.notes (#73505) next »