I have 2 range of numbers:
$startTime to $endTime$offerStartTime to $offerEndTime
//$startTime to $endTime
//$offerStartTime to $offerEndTime
//you can compare php times by using normal comparators so this is just a logic problem. here's the solution.
//ok let's start by making sure that neither offered time is within the range because if it is we KNOW it's already good so
if(($offerStartTime < $endTime && offerStartTime > $startTime) || ($offerEndTime < $endTime && offerEndTime > $startTime)){
return true;
}
//so it's not easily already within the range so we have to test if the lower one is under the starting one but the other is above. ie.
elseif(($offerStartTime < $startTime) && ($offerEndTime > $startTime)){
return true;
}
//so the only other acceptable possibility is that the offered start time is lower than the endtime and the offered end time is higher ie
elseif(($offerStartTime < $endTime) && ($offerEndTime > $endTime)){
return true;
}
//so we've exhausted all other valid possibilities it must be false
else{
return false;
}