我有一個事件日曆的開始和結束日期如下:需要通過開始 - 結束日期循環幫助
16.08.2010 12:00:00
- 21.08.2010 20:00:00
16.08.2010 20:00:00
- 21.08.2010 23:00:00
18.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;
從理論上講,這應該遍歷所有天延伸數天的事件。 但這沒有發生。
的邏輯是錯誤的地方....請幫助:)
現貨!謝謝:) – Steven 2011-01-31 00:18:58