Home >Backend Development >PHP Tutorial >php里的strtotime函数

php里的strtotime函数

WBOY
WBOYOriginal
2016-06-06 20:40:04928browse

<code>    $beginWed=strtotime("-1 week Wednesday");
    $endWed=strtotime("-1 week Thursday")-1;
    $beginThu=strtotime("-1 week Thursday");
    $endThu=strtotime("-1 week Friday")-1;
    $beginFri=strtotime("-1 week Friday");
    $endFri=strtotime("-1 week Saturday")-1;
    $beginSat=strtotime("-1 week Saturday");
    $endSat=strtotime("+0 week Sunday")-1;
    $beginSun=strtotime("+0 week Sunday");
    $endSun=strtotime("+0 week Monday")-1;


    为什么前面要加-1  后面是+0 谁详细解释一下 要把周末作为第一天?
    这里返回的都是本周三的开始时间戳和结束时间戳
</code>

回复内容:

<code>    $beginWed=strtotime("-1 week Wednesday");
    $endWed=strtotime("-1 week Thursday")-1;
    $beginThu=strtotime("-1 week Thursday");
    $endThu=strtotime("-1 week Friday")-1;
    $beginFri=strtotime("-1 week Friday");
    $endFri=strtotime("-1 week Saturday")-1;
    $beginSat=strtotime("-1 week Saturday");
    $endSat=strtotime("+0 week Sunday")-1;
    $beginSun=strtotime("+0 week Sunday");
    $endSun=strtotime("+0 week Monday")-1;


    为什么前面要加-1  后面是+0 谁详细解释一下 要把周末作为第一天?
    这里返回的都是本周三的开始时间戳和结束时间戳
</code>

是的,因为是老外写的,人家的时间设置是从周日开始的。

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