我想知道如何打印PHP 5.2中给出的日期范围之间的所有日期 我不想为此任务调用函数。
答案 0 :(得分:4)
这应该可以胜任。
<?php
$start = '2013/01/01'; //start date
$end = '2013/01/30'; //end date
$dates = array();
$start = $current = strtotime($start);
$end = strtotime($end);
while ($current <= $end) {
$dates[] = date('Y/m/d', $current);
$current = strtotime('+1 days', $current);
}
//now $dates hold an array of all the dates within that date range
print_r($dates);
?>