zoukankan      html  css  js  c++  java
  • PHP计算两个时间段是否有交集(边界重叠不算)

    /**
     * PHP计算两个时间段是否有交集(边界重叠不算)
     *
     * @param string $beginTimeOne 开始时间1
     * @param string $endTimeOne 结束时间1
     * @param string $beginTimeTwo 开始时间2
     * @param string $endTimeTwo 结束时间2
     * @return bool
     */
    protected function isTimeCross($beginTimeOne = '', $endTimeOne = '', $beginTimeTwo = '', $endTimeTwo = '') {
    
    	$statusOne = $beginTimeTwo - $beginTimeOne;
    
    	if ($statusOne > 0){
    		$statusTwo = $beginTimeTwo - $endTimeOne;
    		if ($statusTwo > 0) {
    			return false;
    		} elseif ($statusTwo < 0) {
    			return true;
    		} else{
    			return false;
    		}
    	} elseif ($statusOne < 0) {
    		$statusTwo = $endTimeTwo - $beginTimeOne;
    		if ($statusTwo > 0){
    			return true;
    		} elseif ($statusTwo < 0) {
    			return false;
    		} else {
    			return false;
    		}
    	} else {
    		$statusTwo = $endTimeTwo - $beginTimeOne;
    		if ($statusTwo == 0) {
    			return false;
    		} else {
    			return true;
    		}
    	}
    }
    

      

  • 相关阅读:
    代码解析&Filter用户授权例子
    session
    软件工程结对作业2
    软件工程结对作业1
    软件工程第三次作业
    软件工程第二次作业
    软件工程第一次作业
    KMP算法
    哈希表
    Mysql事物隔离级别
  • 原文地址:https://www.cnblogs.com/spectrelb/p/7347219.html
Copyright © 2011-2022 走看看