I'm trying to get the month, six months out from the current date.
I've tried using:
date('d', strtotime('+6 month', time()));
But it doesn't seem to work, always returns 01
. Is there a better way to do this?
Thank you!
Sample Solution: PHP Code: <? php $dt = strtotime("2012-12-21"); echo date("Y-m-d", strtotime("+1 month", $dt)).
Example 2: PHP Add Months to Current Date$newDate = date('Y-m-d', strtotime(' + 4 months')); echo $newDate; ?>
You can use the EDATE function to quickly add or subtract months from a date. The EDATE function requires two arguments: the start date and the number of months that you want to add or subtract. To subtract months, enter a negative number as the second argument. For example, =EDATE("9/15/19",-5) returns 4/15/19.
If you still wanted to use strtotime and the date function as opposed to a DateTime() object, the following would work:
date('d', strtotime('+6 months'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With