使用此代码,我可以获取开始日期,但不能获取结束日期
$period = new \DatePeriod(new \DateTime($dateStart), new \DateInterval('P1D'), (new \DateTime($dateend)));
我要返回一个日期范围,但是我不使用最后一个日期,在这个示例中,我使用了2天,我选择了第一天而不是第二天,应该是2019-08-05
DatePeriod {#448 ▼
period: every + 1d, from 2019-08-04 00:00:00.0 (included) to 2019-08-05 00:00:00.0
+"start": DateTime @1564876800 {#468 ▼
date: 2019-08-04 00:00:00.0 UTC (+00:00)
}
+"current": null
+"end": DateTime @1564963200 {#457 ▶}
+"interval": DateInterval {#458 ▶}
+"recurrences": 1
+"include_start_date": true
}
如何包含结束日期?
答案 0 :(得分:0)
我通过在最后一天增加1天来解决它
$dateend->modify('+1 day');
$period = new \DatePeriod(new \DateTime($dateStart), new \DateInterval('P1D'), (new \DateTime($dateend)));