从7年开始

use*_*331 0 php date strtotime

我想从这个日期减去7年......

我试过这个并没有用:(我做错了什么?

strtotime("-7 year", strtotime(date("Y")))
Run Code Online (Sandbox Code Playgroud)

这将回应1131498720我正在寻找的答案2005

我忘了提到"-7"是一个变量 $x = -7

Mar*_*c B 7

strtotime返回一个unix时间戳(自1970年1月1日以来的秒数).1131498720对应于2005年11月8日,这是过去7年.

既然你只是减去年限,为什么不简单

$seven_years_ago = date('Y') - 7;
Run Code Online (Sandbox Code Playgroud)