I have some weird behaviour with DateTime class.
Today is 2012-05-31. Timezone is “Europe/Vilnius”.
Following code
$date = new DateTime('last month');
echo $date->format('Y-m-d');
outputs 2012-05-01. Is this a php bug? By the way, $date = new DateTime('-1 month'); outputs the same.
This seems to be special case for months with 31 days:
What you can do is:
And then it depends on what you are going to do with the date.