- reset: documentation ( source)
- print_r: documentation ( source)
- end: documentation ( source)
- explode: documentation ( source)
- iterator_to_array: documentation ( source)
<?php
$dateRange = '2014-01-01 - 2014-01-08';
$parts = explode(' - ', $dateRange);
$begin = new \DateTime($parts[0]);
$end = new \DateTime($parts[1]);
$interval = new \DateInterval('M1D');
$datePeriod = new \DatePeriod($begin, $interval, $end);
$periodArray = iterator_to_array($datePeriod);
$startDate = reset($periodArray);
$endDate = end($periodArray);
#echo $datePeriod->start->format('c');
#echo "\n";
echo $startDate->format('c');
echo "\n";
#echo "\n";
#echo $datePeriod->end->format('c');
#echo "\n";
echo $endDate->format('c');
echo "\n";
echo "\n";
echo print_r($periodArray);