
Here is a small code snippet that will give you intersecting dates between 2 date ranges. Say, for example, you have 2 date ranges, 1-Jan-2011 to 31-Mar-2011 and 23-Feb-2011 to 4-May-2011. This function will give you 23-Feb-2011 to 31-Mar-2011 as result.
Here is the code:
$a1 = "2011-01-01";
$a2 = "2011-03-31";
$b1 = "2011-02-23";
$b2 = "2011-05-04";
$intersection = getIntersection($a1,$a2,$b1,$b2);
if($intersection === false)
{
echo 'No intersecting dates found';
}
else
{
echo 'From '.date('d-M-Y',...
Published on September 06, 2011 13:38