$start=new DateTime('2017-02-20');
$end=new DateTime('2017-03-10');
foreach(new DatePeriod($start,new DateInterval('P1D'),$end) as $d){
/**
* @var $d DateTime
*/
echo $d->format('Y-m-d')."\r\n";
}
输出
2017-02-20
2017-02-21
2017-02-22
2017-02-23
2017-02-24
2017-02-25
2017-02-26
2017-02-27
2017-02-28
2017-03-01
2017-03-02
2017-03-03
2017-03-04
2017-03-05
2017-03-06
2017-03-07
2017-03-08
2017-03-09
参考:http://kaifage.com/notes/133/all-the-dates-in-the-time-period.html