Home >Backend Development >PHP Tutorial >php获取前一天,前一个月,前一年的时间

php获取前一天,前一个月,前一年的时间

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:33:142296browse

获取前一天的时间:

$mytime= date("Y-m-d H:i:s", strtotime("-1 day"));

获取三天前的时间:

$mytime= date("Y-m-d H:i:s", strtotime("-3 day"));

获取前一个月的时间:

$mytime= date("Y-m-d H:i:s", strtotime("-1 month"));

获取前3个月的时间:

$mytime= date("Y-m-d H:i:s", strtotime("-3 month"));

获取前一个小时的时间:

$mytime= date("Y-m-d H:i:s", strtotime("-1 hour"));

获取前一年的时间:

$mytime= date("Y-m-d H:i:s", strtotime("-1 year"));



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