2016-03-15 186 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;