可能重复:
如何在PHP中计算到未来某个时间点的天数?
我想使用PHP生成从开始日期到结束日期的日期。例如,开始日期为2012年1月23日,结束日期为2012月30日。我希望日期生成为2012年1月24日,2012年1月25日,…..
。。。。。2012年1月30日
有什么帮助吗。。。
<?php
$fromDate = '01/23/2012';
$toDate = '01/30/2012';
$dateMonthYearArr = array();
$fromDateTS = strtotime($fromDate);
$toDateTS = strtotime($toDate);
for ($currentDateTS = $fromDateTS; $currentDateTS <= $toDateTS; $currentDateTS += (60 * 60 * 24)) {
// use date() and $currentDateTS to format the dates in between
$currentDateStr = date("Y-m-d",$currentDateTS);
$dateMonthYearArr[] = $currentDateStr;
//print $currentDateStr."<br />";
}
echo "<pre>";
print_r($dateMonthYearArr);
echo "</pre>";
?>