|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-12-16 09:11 UTC] derick@php.net
[2010-08-30 17:35 UTC] derick@php.net
[2010-08-30 17:35 UTC] derick@php.net
-Status: Bogus
+Status: Closed
-Assigned To:
+Assigned To: derick
[2010-08-30 17:35 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
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