note 102841 added to class.dateperiod
| From: | AurelienMarchand at osu1 dot php dot net | Date: | Wed, 09 Mar 2011 20:11:20 +0000 |
| Subject: | note 102841 added to class.dateperiod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177721@lists.php.net to get a copy of this message | ||
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
----
Server IP: 66.207.199.35
Probable Submitter: 209.202.82.139
----
Manual Page -- http://www.php.net/manual/en/class.dateperiod.php
Edit -- https://master.php.net/note/edit/102841
Del: integrated -- https://master.php.net/note/delete/102841/integrated
Del: useless -- https://master.php.net/note/delete/102841/useless
Del: bad code -- https://master.php.net/note/delete/102841/bad+code
Del: spam -- https://master.php.net/note/delete/102841/spam
Del: non-english -- https://master.php.net/note/delete/102841/non-english
Del: in docs -- https://master.php.net/note/delete/102841/in+docs
Del: other reasons-- https://master.php.net/note/delete/102841
Reject -- https://master.php.net/note/reject/102841
Search -- https://master.php.net/manage/user-notes.php