Date difference, PHP

Good evening. Dear, tell me the principle for PHP, how to get all the dates between two dates?


Answer 1, authority 100%

$start = new DateTime(); 
$end = new DateTime('2012-01-01'); 
$interval = new DateInterval('P1D');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $date) {
    echo $date->format('r')."\n";
}

Answer 2, authority 50%

$dates = array();
$time1 = time()-(15 * 86400); // 15  
$time2 = time();
$t = $time1;
do{
  $dates[] = date('d.m.Y', $t);
  $t += 86400;
  } while ($t < $time2);
print_r($dates);

To get a timestamp from a date, use strtotime()