Jump to content

strtowrongtime issue


BoarderLine

Recommended Posts

PHP 5.3.3

 

I am using this to get a date 6 months from:-

 

$today=date("Y-m-d");
$newdate=strtotime(date("Y-m-d", strtotime($today)) . " +6 months");

 

However I am getting the output format:-

 

1299495600 (or similar)

 

The strange thing is this did work with PHP4.

 

Does anyone know why???????????

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/212834-strtowrongtime-issue/
Share on other sites

Thanks rwwd,

 

I should have explained a little more about the problem.  In the example given I am using $today=date("Y-m-d") however in my code the $today variable can be substituted for any date not just today.  So really what I am needing is the strtotime() function to generate +6 months from a dynamic date.

Strtotime() only returns int:http://uk3.php.net/manual/en/function.strtotime.php so in the context of your example your output would be: 1299495600 (or similar)

 

what you would need then is this:-

 

$today = "Y-m-d";
echo $newdate = date($today, strtotime("+6 months"));

 

Hope that makes sense, Ideally though strtotime is used inside the date() function as the second parameter, purely because it returns an int that the date() function can interpret..

 

Cheers,

Rw

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.