网站首页 博客 php日期加减处理函数
昨天:
echo date('Y-m-d',strtotime('-1 day'));
明天:
echo date('Y-m-d',strtotime('+1 day'));
其中的参数day可以改成year(年),month(月),hour(小时),minute(分),second(秒)
例如一个月之前:
echo date('Y-m-d',strtotime('-1 month'));
一年之后:
echo date('Y-m-d',strtotime('+1 year'));
指定开始日期:
echo date('Y-m-d',strtotime('+10 day', strtotime('2016-05-09')));
这个获取的是从2016-05-09开始10天之后的日期