如何显示从28-10-2014
到01-11-2014
的日期范围?
28-10-2014
29-10-2014
30-10-2014
31-10-2014
01-11-2014
答案 0 :(得分:2)
试试这个:
<?php
$begin = new DateTime('28-10-2014');
$end = new DateTime('01-11-2014');
$daterange = new DatePeriod($begin, new DateInterval('P1D'), $end);
foreach($daterange as $date){
echo $date->format("m-d-Y");
}
?>
答案 1 :(得分:1)
<?php
$date = "10-28-2014";
$date1 = str_replace('-', '/', $date);
$iterations = 4;
for ($i=0 ; $i<= $iterations ; $i++) {
$tomorrow = date('d-m-Y',strtotime($date1 . "+$i days"));
echo '<br/>'.$tomorrow;
}
?>
希望这有效。