🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ >>> date('Y-m-28', strtotime("2016-12-31 -1 month")) => "2016-12-28" >>> date('Y-m-28', strtotime("2016-01-31 +1 month")) => "2016-03-28" >>> date('Y-m-d', strtotime("2016-01-31 first day of +1 month")) => "2016-02-01" $d = new DateTime('2015-01-31'); $d->modify('first day of next month'); echo $d->format('Y-m-28'); $d = new DateTime('2015-01-31'); $d->modify('first day of next month'); echo $d->format('Y-m-28'); MySQL: DATE_ADD('2011-01-31', INTERVAL 1 MONTH) returns 2011-02-28 ~~~ 获取上周一的时间 ~~~ >>> date('Y-m-d H:i:s',strtotime('-2 monday')) => "2016-10-03 00:00:00" $days = date('w')==0?13:date('w')+6; echo date('Y-m-d',time()-$days*86400); date('Y-m-d', strtotime('-' . (6+date('w')) . ' days')); ~~~