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

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

WBOY
WBOYOriginal
2016-05-17 09:08:221560browse

如果你想根据时间来判断某一时间值(用秒数表示)是否在今天的范围之内。下面这个函数,将帮你轻而易举的判断。
函数源代码:
---------------------------------------------
说明:若$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;
    }
}

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

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