Level 102
You should be able to use carbon period
$period = new CarbonPeriod('2020/10/11 09:30', '30 minutes', '2020/10/11 17:30');
foreach ($period as $time) {
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
assume I have two dates:
2020/10/11 09:30 - 2020/10/11 17:30 I want to generate a date period using carbon and increment every 30 minutes like so:
2020/10/11 09:30
2020/10/11 10:00
2020/10/11 10:30
all the way to 2020/10/11 17:30
how to achieve that using carbon?
You should be able to use carbon period
$period = new CarbonPeriod('2020/10/11 09:30', '30 minutes', '2020/10/11 17:30');
foreach ($period as $time) {
Please or to participate in this conversation.