xref: /PHP-7.4/ext/date/tests/bug52668.phpt (revision ab6789a0)
1--TEST--
2Bug #52668 (Iterating over a dateperiod twice is broken)
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$start    = new DateTime('20101212');
8$interval = DateInterval::createFromDateString('next day');
9$dp = new DatePeriod($start, $interval, 1);
10foreach($dp as $dt) {
11    echo $dt->format('r') . "\n"; // Sun, 12 Dec 2010 00:00:00 +0100
12}
13echo $start->format('r'), "\n";
14foreach($dp as $dt) {
15    echo $dt->format('r') . "\n"; // Sun, 12 Dec 2010 00:00:00 +0100
16}
17echo $start->format('r'), "\n\n";
18?>
19--EXPECT--
20Sun, 12 Dec 2010 00:00:00 +0000
21Mon, 13 Dec 2010 00:00:00 +0000
22Sun, 12 Dec 2010 00:00:00 +0000
23Sun, 12 Dec 2010 00:00:00 +0000
24Mon, 13 Dec 2010 00:00:00 +0000
25Sun, 12 Dec 2010 00:00:00 +0000
26