Simon Fabb Simon Fabb - 8 months ago 44
PHP Question

PHP date from today to 4 months

Does anyone know why this keeps on showing the date 01-05-70?

$effectiveDate = strtotime("+4 months", strtotime($effectiveDate)); // returns timestamp
echo date('d-m-y',$effectiveDate); // formatted version

I want it to print today's date + 4 months.


In your code $effectiveDate contains an invalid date. So strtotime() returns the unix epoch Jan 1, 1970.

But you shouldn't need that variable at all if all you want is the date four months from now.

echo date('d-m-y',strtotime('+4 months'));