I built a function a while back to handle this problem, it may be a little clunky, but it works.
The date I was formatting looked like this: 2000-12-31. I've modified the function so it should meet your needs, you can have it reaarange the format by changing the last line in the function.
The reason it is so clunky is because I found that PHP drops the '0' off the front of the date when you try to back it up. For this reason, I had to do a loop to check to see if the date was supposed to have a '0' in front of it. The zero was very important to me in matching up dates within my database.
function previousDate(&$inputdate) {
$date = explode("/", $inputdate);
$month = $date[1];
$year = $date[2];
$day = $date[0];
if (($month == "1") && ($day == "1")) {
$month = "12";
$year = --$year;
$day = "31";
} else if(($month == "1") && ($day != "1")) {
$day = $day - "01";
} else if (($month != "1") && ($day == "1")) {
$month = --$month;
$day = "31";
} else {
$day = --$day;
}
if ($day <= "9") {
$addzero = "0";
$addzero .= $day;
$day = $addzero;
} else {
}
if (($month <= "9") && ($day == "31")) {
$addzero = "0";
$addzero .= $month;
$month = $addzero;
} else {
}
$inputdate = "$day/$month/$year";
}
You probably know, but just in case, call the function by:
$date = "22/02/2002";
$date = previousDate($date);
Date returned will be:
21/02/2002