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......
views:
33answers:
3
A:
$nb_days = (strtotime($period1[1])-strtotime($period2[0])) / 86400
Should work.
MatTheCat
2010-10-05 13:11:51
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
2010-10-05 13:18:06