在PHP中添加日期的错误结果

Hi I have a problem to add one week to a current date so when I do :

 $date = date('Y-m-d');

 $OneWeek = strtotime(date("Y-m-d", strtotime($date)) . "+1 week");

 var_dump($OneWeek);

So I get something like that:

             1354230000

but I hope to have a result like that

2012/11/30 + 1 week =>   2012/12/07

I don't know what's wrong?

use this and learn these functions..

http://www.php.net/manual/en/function.strtotime.php
http://www.php.net/manual/en/function.date.php

echo date("Y-m-d", strtotime($date . " +1 week"));

strtotime() returns a timestamp - an integer. You simply have to convert it into a date:

echo date('Y-m-d', strtotime('+1 week')); // 2012-12-07

Also you don't need current timestamp, strtotime uses current time when relative time definitions are used (like 'next Thursday' or '+1 week')

strtotime() return a Unix timestamp, date()a formatted date.

To do what you want:

$date = strtotime('today'); 
echo date("Y-m-d", strtotime($date . " +1 week")); // '2012-12-07'

Note the space in " +1 week".

It makes the difference between these two:

strtotime("2012-01-01" . "+1 week") // strtotime("2012-01-01+1 week")
strtotime("2012-01-01" . " +1 week") // strtotime("2012-01-01 +1 week")