Well, the following returns what date was 5 days ago:
$days_ago = date(\'Y-m-d\', mktime(0, 0, 0, date(\"m\") , date(\"d\") - 5, date(\"Y\")));
simple way to find the same is
$date = date("Y-m-d", strtotime('-5 days', strtotime('input_date')));
General algorithms for date manipulation convert dates to and from Julian Day Numbers. Here is a link to a description of such algorithms, a description of the best algorithms currently known, and the mathematical proofs of each of them: http://web.archive.org/web/20140910060704/http://mysite.verizon.net/aesir_research/date/date0.htm
I think a readable way of doing that is:
$days_ago = date('Y-m-d', strtotime('-5 days', strtotime('2008-12-02')));
find out what the date was 5 days ago from today in php
$date = strtotime(date("Y-m-d", strtotime("-5 day")));
find out what the date was n days ago from today in php
$date = strtotime(date("Y-m-d", strtotime("-n day")));