方法整理自:https://stackoverflow.com/questions/18742998/how-to-list-all-months-between-two-dates
修改后的代码如下:
$arr = array();
$start = new DateTime('2017-09-02');
$start->modify('first day of this month');
$end = new DateTime(gmdate("Y-m-d", time()+8 * 3600));
$end->modify('first day of next month');
$interval = DateInterval::createFromDateString('1 month');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $dt) {
$arr['date'][] = $dt->format("Ym");
}
如您从本文得到了有价值的信息或帮助,请考虑扫描文末的二维码对我进行赞赏和鼓励。
如本文对您有用,捐赠和留言 将是对我最好的支持~(捐赠可以转换为站内积分哦)
如愿意,请向朋友推荐本站,谢谢。
尊重他人劳动成果。 转载请务必附上原文链接,我将感激不尽。
有问题可以通过文末留言给我。
留言