Adding year on to date string

Hi all. Being stewing over this all morning now and i have gotten no where !! please help if you can.

I have a form where the person selects how many years to add on to the current date this is basically to recommend the next test date of an item.

I have shortened all this down for you all to see what i am trying to accomplish.
[php]
$testint (is sent from my form.) This is either a 1 or a 4.

i pick up the current date and time $today = date(‘Y-m-d H:i:s’);

i then want to add $testint (number of years) on to the $today and then have a date string to put in mysql.

and then i insert this in to my mysql.
[/php]

I have tried a few way to do this but nothing seems to work for me.

Hope this makes some sense.

Paul

[php]date_default_timezone_set(‘America/Detroit’);

$date = new DateTime();

$todaysDate = $date->format(‘Y-m-d H:i:s’);

$testint = 4;

$futureDate = date(‘Y-m-d H:i:s’, strtotime(“now +” . $testint . ‘years’ ));

echo 'Today date is ’ . $todaysDate . ’ and ’ . $testint . ’ years from now it will be ’ . $futureDate;
[/php]

You ROCK !!

Thank you so much.

Paul

Sponsor our Newsletter | Privacy Policy | Terms of Service