Home  >  Article  >  Backend Development  >  一个关于时间有关问题

一个关于时间有关问题

WBOY
WBOYOriginal
2016-06-13 13:44:57775browse

一个关于时间问题
当前的日期通过控件获得:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$thisday = $_GET['calendar'];

现在我想求这个日期的前一天(查询日历日期的前一天),怎么求?

注:日历的字符串形式 Y-m-d

------解决方案--------------------
-1day
------解决方案--------------------
echo date('Y-m-d', strtotime("-1 day $thisday"));
------解决方案--------------------
如果$_GET['calendar']的时间格式类似“2012-02-14 11:56:30”,则先转换为time格式:strtotime($_GET['calendar'])
然后减去一天的秒数就可以啦:strtotime($_GET['calendar'])-60*60*24

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