I have used this :
$date = date("Y-m", strtotime("-2 months"));
and it is gives "2016-12" but what i needed is "2016-11".
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
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.