企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ >>> 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')); ~~~