我正试着从日期中减去7年...
我试过了,但它不起作用:(我做错了什么?
strtotime("-7 year", strtotime(date("Y")))这就是我要找的答案是2005。
我忘记提到"-7“是一个变量$x = -7
发布于 2012-11-08 22:56:56
strtotime返回unix时间戳(自1970年1月1日以来的秒数)。1131498720相当于2005年11月8日,也就是过去的7年。
既然你只是在减去年份,为什么不干脆
$seven_years_ago = date('Y') - 7;发布于 2012-11-08 22:57:04
尝试:
$str = date('Y', strtotime(date('Y') . " -7year"));
echo $str;Demo
https://stackoverflow.com/questions/13291410
复制相似问题