php 获取前一天/月/年的时间

308 阅读1分钟
获取前一天的时间:

date("Y-m-d H:i:s", strtotime("-1 day"));
获取前一个月的时间:

date("Y-m-d H:i:s", strtotime("-1 month"));
获取前一个小时的时间:

date("Y-m-d H:i:s", strtotime("-1 hour"));
获取前一年的时间:

date("Y-m-d H:i:s", strtotime("-1 year"));

date(DATE_ISO8601):2021-05-11T17:00:36+0800

ISO 8601时间格式