note 81499 deleted from function.date by derick

From: Date: Wed, 07 May 2008 18:16:10 +0000
Subject: note 81499 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139141@lists.php.net to get a copy of this message
Note Submitter: dizyn at hotmail dot com M dot Abdul Mannan ---- This small snippet of code will calculate date after five business days. This will exclude Sunday, Saturday and the holidays list that’s given in array. Date for example: 1st March 2008 <?php $holidayList = array("04-03-2008","07-03-2008"); $j = $i = 1; while($i <= 5) { $day = strftime("%A",strtotime("+$j day")); $tmp = strftime("%d-%m-%Y",strtotime("+$j day")); if($day != "Sunday" and $day != "Saturday" and !in_array($tmp, $holidayList)) { $i = $i + 1; $j = $j + 1; } else $j = $j + 1; } $j = $j -1; echo strftime("%A, %d-%m-%Y",strtotime("+$j day")); ?> Result: Tuesday, 11-03-2008

« previous php.notes (#139141) next »