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"); $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