DatePeriod is a PHP class for handling recurring dates. It has a very limited number of methods. So when I want to do basic array functions with the recurring dates, I have to copy it to an array with iterator_to_array
. Strangely, copying it seems to clobber it. Any ideas why?
$p=new DatePeriod(date_create('2008-01-01'),
DateInterval::createFromDateString( "+2 days" ),
date_create('2008-12-31'));
echo count(iterator_to_array($p)); //183
$a=iterator_to_array($p);
echo count($a); //0