while coding for blogmatch today, I wrote a simple function. it returns the date that’s N days from a date you specify. For example, if you provide 2004/03/01 as the input date, it should return 2004/02/29 if you want to find out the date right before 2004/03/01.
The function is pretty straight forward and handy. You provide a date with its month, day and year and how many days before or after that date. It will return an array with keys: year, month and day. read more about it here or you can get the complete source code plus examples here.