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

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.

| improve this answer | |
1

I have used :

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

| improve this answer | |
  • This is working for me – vijay Feb 14 '17 at 7:31

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