PHP判断某时间段是否包含周末代码

WBOY
Release: 2016-06-20 13:01:59
Original
1481 people have browsed it

有两个已知时间戳。判断该时间戳内是否包含周六周天。

/**
*判断时间段是否有周末。
* @author 
* @version 2015年10月10日17:36:27
* @param begin 开始时间
* @param last 结束时间
*/

public function isWeek($begin,$last){
    $span = intval($last-$begin);
    if($span >= 604800){
    return 1;
    }else if($span > 0){
    $lWeek = date(‘w’,$last);
    $bWeek = date(‘w’,$begin);
    if($lWeek == 6 || $lWeek == 0 || $bWeek == 6 || $bWeek == 0){
    return 1;
    }else{
    if($bWeek > $lWeek){
    return 1;
    }else{
    return 0;
    }
    }
    }
}
Copy after login

 


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template