如果你正在使用PHP
$start = new DateTime('1-1-2017');
$end = new DateTime('4-1-2017');
将日期分为3
结果:
array(
array('start'=> 1-1-2017,'end'=>2-1-2017),
array('start'=> 2-1-2017,'end'=>3-1-2017),
array('start'=> 3-1-2017,'end'=>4-1-2017)
);
谢谢
答案 0 :(得分:0)
试试这个.. !!
使用DateTime迭代日期:
$start = new DateTime('1-1-2017');
$end = (new DateTime('4-1-2017'))->modify('+1 day');
$interval = new DateInterval('P1D');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $dt) {
echo $dt->format("d-m-y") . "<br>\n";
}