Read 199 times | Created 2016-04-23 00:18:16 | Updated 2016-04-23 00:32:32 | | |

 

<?php
 function add_business_days($startdate,$buisnessdays,$holidays,$dateformat){
  $i=1;
  $dayx = strtotime($startdate);
  while($i < $buisnessdays){
   $day = date('N',$dayx);
   $date = date('Y-m-d',$dayx);
   if($day < 6 && !in_array($date,$holidays))$i++;
   $dayx = strtotime($date.' +1 day');
  }
  return date($dateformat,$dayx);
 }
 
 //Example 17days from 2015-12-29
 date_default_timezone_set('Asia/Jakarta');
 $startdate = '2015-12-29';
 $holidays=array("2016-01-01");
 echo '<p>Start date: '.date('r',strtotime( $startdate));
 echo '<p>'.add_business_days($startdate,17,$holidays,'Y-m-d');