0

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!

Edited by LastMitch: grammer

2
Contributors
3
Replies
5
Views
4 Years
Discussion Span
Last Post by LastMitch
1
echo date('Y-m-d',strtotime("+2 month"));

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

Votes + Comments
Thanks for the explanation & solution!
0

@diafol

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

0

@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

Edited by LastMitch: grammer

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.