From: php at michaelcrumley dot com
Operating system: WIN32
PHP version: 5.3.0alpha3
PHP Bug Type: Date/time related
Bug description: DatePeriod not resetting after foreach loop
Description:
------------
After looping through a DatePeriod object, the current date is not reset
so looping again starts at the same date. Maybe that is the intended
behavior, but I would expect it to start at the same date each time.
Reproduce code:
---------------
$dp = new DatePeriod('R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M');
foreach ($dp as $date) {
echo $date->format("Y-m-d H:i:s\n");
}
echo "\n";
// this should repeat the same range
foreach ($dp as $date) {
echo $date->format("Y-m-d H:i:s\n");
}
Expected result:
----------------
2008-03-01 13:00:00
2009-05-11 15:30:00
2010-07-21 18:00:00
2011-10-01 20:30:00
2012-12-11 23:00:00
2014-02-22 01:30:00
2008-03-01 13:00:00
2009-05-11 15:30:00
2010-07-21 18:00:00
2011-10-01 20:30:00
2012-12-11 23:00:00
2014-02-22 01:30:00
Actual result:
--------------
2008-03-01 13:00:00
2009-05-11 15:30:00
2010-07-21 18:00:00
2011-10-01 20:30:00
2012-12-11 23:00:00
2014-02-22 01:30:00
2015-05-02 04:00:00
2016-07-12 06:30:00
2017-09-22 09:00:00
2018-12-02 11:30:00
2020-02-12 14:00:00
2021-04-22 16:30:00
--
Edit bug report at http://bugs.php.net/?id=46874&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46874&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46874&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46874&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=46874&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=46874&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=46874&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=46874&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=46874&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=46874&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=46874&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=46874&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46874&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46874&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=46874&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46874&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46874&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=46874&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=46874&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=46874&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=46874&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=46874&r=mysqlcfg