Member Avatar for LastMitch

Hi

I having issue trying to add 2 months from the date() function?

Here is my code:

<?php 

// current date
$todayDate = date("Y-m-d");

echo "Today: ".$todayDate."<br>";

// Two months from now is Christmas!
echo "strtotime($todayDate) . "+2 month")";

echo "Today is Christmas: strtotime('l dS \o\f F Y', $todayDate)";

?>

Any Suggestions and explanation will help. I appreciate it. Thanks!

Member Avatar for diafol
echo date('Y-m-d',strtotime("+2 month"));

is what you need to increment today's date by 2 months.

commented: Thanks for the explanation & solution! +5
Member Avatar for LastMitch

@diafol

Thanks for the reply & explantion. I will test out the code that you provided. Thanks!

Member Avatar for LastMitch

@diafol

It worked! Thanks for the explanation and I appreciate it your help! Thanks!

Here is my new (modify) code base your code:

<?php 
// current date
$todayDate = date("m-d-Y");
echo "Today date is: ".$todayDate."<br/><br/>";
// Two months from now is Christmas!
echo "Two months from now is Christmas: ".date('m-d-Y',strtotime("+2 month"));
?>

This what it echo out:

Today date is: 10-20-2012

Two months from now is Christmas: 12-20-2012
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.