在 PHP 中获取正好一周前的时间戳?

2022-08-30 12:07:56

我需要使用PHP计算正好7天前的时间戳,因此,如果当前是3月25日晚上7:30,它将返回3月18日晚上7:30的时间戳。

我应该从当前时间戳中减去604800秒,还是有更好的方法?


答案 1
strtotime("-1 week")

答案 2

strtotime是你的朋友

echo strtotime("-1 week");

推荐