2012-01-23 18 views
-3

可能性の重複:
How to calculate days till some point in future in PHP?PHPを使って日付を自動的に生成するには?

私はPHPを使用して終了日に開始日から日付を生成したいと思います。 たとえば、開始日が2012年1月23日で、終了日は、私は日付が 2012年1月24日、 2012年1月25日、 .....
として生成されるようにしたい1月30日、2012年 です..... 2012年1月30日

すべてのヘルプ、plsは...マイナーな変更を加えて

+0

、問題の答え[PHPにおける将来のある時点までの日数を計算する方法は?] (http://stackoverflow.com/questions/4554667/how-to-calculate-days-till-some-point-in-future-in-php)を使用することができます。 –

答えて

0
<?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>"; 
?> 
関連する問題