2016-03-15 235 views

回答

1

有一个PHP函数调用的strtotime(): http://php.net/manual/en/function.strtotime.php

这应该是你在寻找的东西。

+1

如果您要参考PHP.net,请使用英文版本。如“en”而不是“de”。不多*“sprachen sie deutsch”* ;-) http://stackoverflow.com/revisions/36012645/1 –

+0

对不起,我没有注意到它;)编辑 – Stefan

+0

* grazie mille * ;-) –

0

您可以使用strtotime。

$curdate = strtotime("2015-13-03 12:06:03"); 

$newdate = strtotime("+1 day",$curdate); 
0

我的方法是这样:

$date = new DateTime('2000-12-31 12:06:03'); 
$date->modify('-1 day'); 
echo $date->format('Y-m-d H:i:s') . "\n"; 

,但也有多个道路。

0

你不能只分配时间字符串创建日期变量..结帐这个..

$curdate = date("Y-m-d H:i:s",mktime(12,06,03,03,13,2015)); 
$yesterday = date('Y-m-d H:i:s', strtotime('-1 day', strtotime($curdate))); 
$twodaysbefore = date('Y-m-d H:i:s', strtotime('-2 day', strtotime($curdate))); 
echo "yesterday: " . $yesterday."-- 2 day before :".$twodaysbefore; 
相关问题