views:

33

answers:

3

I want to find out common days/dates between two periods for example [period1 - 25/10/2010 - 25-11-2010 ] and [ period2 - 10-11-2010 - 10-12-2010 ]...here 15 days 26-10 to 10-11 are common....how can I find it in PHP or Zend Framework..... Thanks in Advance......

A: 
$nb_days = (strtotime($period1[1])-strtotime($period2[0])) / 86400

Should work.

MatTheCat
A: 

Using NullUserException's suggested method

date_default_timezone_set('GMT');


$period1 = array('25-10-2010','25-11-2010');
$period2 = array('10-11-2010','10-12-2010');

$p1 = range(strtotime($period1[0]),strtotime($period1[1]),86400);
$p2 = range(strtotime($period2[0]),strtotime($period2[1]),86400);

$r = array_intersect($p1,$p2);

foreach($r as $date) {
 echo $date,' - ',date('d-M-Y H:i:s',$date),'<br />';
}
Mark Baker
A: 

Thanks Mark

It Works.........

irshad