Possible Duplicate:
How to get previous month and year relative to today, using strtotime and date?
Today is December, 31st but strtotime("-1 months") returns December:
echo date("Y-m", strtotime("-1 months"));
Same for strtotime("last month")
How can I properly return the previous month (November)?
Test: http://codepad.viper-7.com/XvMaMB
strtotime("first day of last month")
The first day of is the important part as detailed on the Relative Formats manual page.
Example: http://codepad.viper-7.com/dB35q8 (with hard-coded today's date)
strtotime("-1 months") would be 2012-11-31, but there's no November, 31st. It is one day past 2012-11-30, which gives 2012-12-01. You will see it, when you do 
echo date("Y-m-d", strtotime("-1 months"));
gives as output
2012-12-01
See codepad
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