运用了date()和strtotime()函数,直接上代码
echo date('Y-m-d' , strtotime('-1 day')).PHP_EOL; echo date('Y-m-d' , strtotime('-1 week')).PHP_EOL; echo date('Y-m-d' , strtotime('-1 month')).PHP_EOL; echo date('Y-m-d' , strtotime('-1 year')).PHP_EOL; /** 输出 2014-03-24 2014-03-18 2014-02-25 2013-03-25 **/