I need to get previous month and year, relative to current date.
However, see following example.
// Today is 2011-03-30 echo date(\'Y-m-d\', strtotim
Have a look at the DateTime class. It should do the calculations correctly and the date formats are compatible with strttotime. Something like:
strttotime
$datestring='2011-03-30 first day of last month'; $dt=date_create($datestring); echo $dt->format('Y-m'); //2011-02