Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function dates() {
- yield new DateTimeImmutable('2020-01-01');
- yield new DateTimeImmutable('2020-01-02');
- yield new DateTimeImmutable('2020-01-05');
- yield new DateTimeImmutable('2020-01-06');
- yield new DateTimeImmutable('2020-01-10');
- }
- $next = new DateTimeImmutable('2020-01-01');
- foreach (dates() as $date) {
- while ($date != $next) {
- echo $next->format('Y-m-d H:i:s') . '<br>';
- $next = $next->add(new DateInterval('P1D'));
- }
- echo $date->format('Y-m-d H:i:s') . '<br>';
- $next = $next->add(new DateInterval('P1D'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement