/**
 * 获取指定日期段内每一天的日期
 * @param  Date  $startdate 开始日期
 * @param  Date  $enddate   结束日期
 * @return Array
 */
function getDateFromRange($startdate, $enddate){

    $stimestamp = strtotime($startdate);
    $etimestamp = strtotime($enddate);

    // 计算日期段内有多少天
    $days = ($etimestamp-$stimestamp)/86400+1;

    // 保存每天日期
    $date = array();

    for($i=0; $i<$days; $i++){
        $date[] = date('Y-m-d', $stimestamp+(86400*$i));
    }

    return $date;
}

$startdate = '2016-08-29';
$enddate = '2016-09-29';
// demo
$date = getDateFromRange($startdate,$enddate);
print_r($date);

  

相关文章:

  • 2021-06-23
  • 2021-12-16
  • 2021-06-26
  • 2022-12-23
  • 2021-09-04
  • 2022-01-27
猜你喜欢
  • 2022-12-23
  • 2021-05-21
  • 2021-07-25
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案