It’s really wired
as on 30-APR-12
both :
date("M", strtotime("-2 months"));
date("M", strtotime("-1 months"));
giving me same result like :
Mar
Mar
on any other day it is ok. I’m too new to call it anything tell me what should i do?
I’ve XAMPP 1.7.4 package (PHP 5.3.5)
The two dates you are actually getting back are:
The behavior of
strtotime()is a bit tricky when it comes to months like this. If you go back two months, there is no 30th of February, so you end up on March 1st. Back 1 month is the behavior you expect.To fix this problem, just use the month portion when using
strtotime().Just replace the year/month with the current one.