Home  >  Article  >  Backend Development  >  PHP function to compare whether there is an intersection between time periods and time periods

PHP function to compare whether there is an intersection between time periods and time periods

怪我咯
怪我咯Original
2017-07-07 09:29:081531browse

PHPCompare the implementation code of time period one and time period two to see if there is any intersection. Friends who need it can refer to it.

The code is as follows:

/* 
*比较时间段一与时间段二是否有交集 
*/ 
function isMixTime($begintime1,$endtime1,$begintime2,$endtime2) 
{ 
$status = $begintime2 - $begintime1; 
if($status>0){ 
$status2 = $begintime2 - $endtime1; 
if($status2>0){ 
return false; 
}else{ 
return true; 
} 
}else{ 
$status2 = $begintime1 - $endtime2; 
if($status2>0){ 
return false; 
}else{ 
return true; 
} 
} 
}

The above is the detailed content of PHP function to compare whether there is an intersection between time periods and time periods. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn