从7年开始

I am trying to subtract 7 years from the date...

I tried this and it did not work :( what am I doing wrong?

strtotime("-7 year", strtotime(date("Y")))

this would echo out 1131498720 the answer I am looking for is 2005

I forgot to mention that "-7" is a variable $x = -7

strtotime returns a unix timestamp (seconds since Jan 1/1970). 1131498720 corresponds to Nov 8/2005, which IS 7 years in the past.

Since you're just substracting years, why not simply

$seven_years_ago = date('Y') - 7;

Try:

$str = date('Y', strtotime(date('Y') . " -7year"));
echo $str;

Demo