Home > php教程 > php手册 > 判“新”函数:得到今天与明天的秒数

判“新”函数:得到今天与明天的秒数

WBOY
Release: 2016-06-13 12:41:22
Original
1403 people have browsed it

如果你想根据时间来判断某一时间值(用秒数表示)是否在今天的范围之内。下面这个函数,将帮你轻而易举的判断。
函数源代码:
---------------------------------------------
说明:若$varTime在今天的范围内,返回ture,否则返回false.
function bTodayToTomorrow($varTime)
{
    $nowYear=date("Y");
    $nowMonth=date("n");
    $nowDay=date("j");
    $aryTodayAndTomorrow["Today"]=date("U",mktime(0,0,0,$nowMonth,$nowDay,$nowYear));
    $aryTodayAndTomorrow["Tomorrow"]=date("U",mktime(0,0,0,$nowMonth,($nowDay+1),$nowYear));
    if($varTime>=$aryTodayAndTomorrow["Today"]&&$varTime    {
        return true;
    }
    else
    {
        return false;
    }
}

------------------
类似的你可以进行任意时间段的判断。 

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template