Current date + 2 months

morgi picture morgi · May 14, 2012 · Viewed 76.3k times · Source

I wrote this piece of code in order to display the current date + 2 months :

<?php
    $date = date("d/m/Y");
    $date = strtotime(date("d/m/Y", strtotime($date)) . "+2 months");
    $date = date("d/m/Y",$date);
    echo $date;
?>

It does not seem to work as it displays : 01/03/1970.

What am I doing wrong?

Thanks for your help.

EDIT :

After reading comments and answers, I simplified and corrected it.

<?php
    $date = date("d/m/Y", strtotime(" +2 months"));
    echo $date;
?>

Answer

Alix Axel picture Alix Axel · May 14, 2012

You're missing the second argument for the second strtotime() call:

echo date('d/m/Y', strtotime('+2 months'));