php根据开始日期和结束日期得到时间数组

话不多说,直接上代码。

$stime=$stime;//开始时间
$etime=$etime;//结束时间
while($stime <= $etime){
$datearr[] = date('Y-m-d',$etime);//得到dataarr的日期数组。
$etime=$etime - 3600*24;
}

比如开始时间为2014-11-01,结束时间为2014-11-30

则数组为

Array ( [0] => 2014-11-30 [1] => 2014-11-29 [2] => 2014-11-28 [3] => 2014-11-27 [4] => 2014-11-26 [5] => 2014-11-25 [6] => 2014-11-24 [7] => 2014-11-23 [8] => 2014-11-22 [9] => 2014-11-21 [10] => 2014-11-20 [11] => 2014-11-19 [12] => 2014-11-18 [13] => 2014-11-17 [14] => 2014-11-16 [15] => 2014-11-15 [16] => 2014-11-14 [17] => 2014-11-13 [18] => 2014-11-12 [19] => 2014-11-11 [20] => 2014-11-10 [21] => 2014-11-09 [22] => 2014-11-08 [23] => 2014-11-07 [24] => 2014-11-06 [25] => 2014-11-05 [26] => 2014-11-04 [27] => 2014-11-03 [28] => 2014-11-02 [29] => 2014-11-01 )

版权声明:本文为博主原创文章,未经博主允许不得转载。

你可能感兴趣的:(php根据开始日期和结束日期得到时间数组)