0

I have used this :

$date = date("Y-m", strtotime("-2 months"));

and it is gives "2016-12" but what i needed is "2016-11".

1

2 Answers 2

2

I have used :

$fdate = date('Y-m', strtotime('first day of -2 month'));

1
  • This is working for me
    – Vijay
    Feb 14, 2017 at 7:31
1

If you try to change format to dmY for example: echo date("dmY", strtotime("-2 months")); You will see that result is 01122016.

You can check comments from this question also: https://stackoverflow.com/questions/10586615/current-date-2-months

And you can check solution here: https://stackoverflow.com/questions/9058523/php-date-and-strtotime-return-wrong-months-on-31st

Pass second parameter.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.