note 102841 deleted from class.dateperiod by cmb

From: Date: Mon, 18 Mar 2019 10:13:20 +0000
Subject: note 102841 deleted from class.dateperiod by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210397@lists.php.net to get a copy of this message
Note Submitter: Aurelien Marchand ---- Warning About DatePeriod for Some Versions of PHP ***************************************** Some versions of PHP had a bug so that caused DatePeriod to act strangely. For instance, the following code: <?php $start = DateTime::createFromFormat("Y-m-d H:i:s","2011-01-01 00:00:00",new DateTimeZone("America/Toronto")); $interval = new DateInterval("P1M"); // 1 month $occurrences = 3; $period = new DatePeriod($start,$interval,$occurrences); foreach($period as $dt){ echo $dt->format("Y-m-d H:i:s") . "\n"; } foreach($period as $dt){ echo $dt->format("Y-m-d H:i:s") . "\n"; } ?> Would produce the following text: 2011-01-01 00:00:00 2011-02-01 00:00:00 2011-03-01 00:00:00 2011-04-01 00:00:00 2011-05-01 00:00:00 2011-06-01 00:00:00 2011-07-01 00:00:00 2011-08-01 00:00:00 Instead of: 2011-01-01 00:00:00 2011-02-01 00:00:00 2011-03-01 00:00:00 2011-04-01 00:00:00 2011-01-01 00:00:00 2011-02-01 00:00:00 2011-03-01 00:00:00 2011-04-01 00:00:00 5.3.2 fails 5.3.3 fails 5.3.4 -??- 5.3.5 works

« previous php.notes (#210397) next »