【发布时间】:2011-01-30 23:57:00
【问题描述】:
我有一个活动日历,开始和结束日期如下:
16.08.2010 12:00:00 - 21.08.2010 20:00:0016.08.2010 20:00:00 - 21.08.2010 23:00:0018.08.2010 17:00:00 - 18.08.2010 19:00:00
每当一个事件持续超过一天时,我就需要每天循环播放。
我找到了这个帖子,我认为它可以帮助我:How to find the dates between two specified date?
我无法使用 PHP 5.3 的解决方案,因为我的服务器运行 PHP 5.2。
其他解决方案不产生输出。
这是我尝试做的:
$events = $data['events'];
foreach($ev as $e) :
$startDate = date("Y-m-d",strtotime( $e->startTime ));
$endDate = date("Y-m-d",strtotime( $e->endTime ));
for($current = $startDate; $current <= $endDate; $current += 86400) {
echo '<div>'.$current.' - '.$endDate.' - '.$e->name.'</div>';
}
endforeach;
理论上,对于持续数天的事件,这应该循环所有天。 但这并没有发生。
逻辑有问题....请帮忙:)
【问题讨论】: