码迷,mamicode.com
首页 > Web开发 > 详细

PHP bug strtotime

时间:2016-05-31 16:10:41      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:error date strtotime

echo date(‘Y-m‘,strtotime(‘-1 months‘));
echo "\r\n";
echo date(‘Y-m‘,strtotime(‘first day of last month‘));
echo "\r\n";
echo date(‘Y-m‘,strtotime(‘-1 week‘));


技术分享


当遇到月为31日是 date(‘Y-m‘,strtotime(‘-1 months‘));求的月份还是当月的

正确使用方式

echo date(‘Y-m‘,strtotime(‘first day of last month‘));


echo date(‘Y-m-d H:i:s‘, strtotime(‘-1 month‘, strtotime(date(‘Y-m‘))));

PHP bug strtotime

标签:error date strtotime

原文地址:http://ouyangjun.blog.51cto.com/10284323/1784839

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!