码迷,mamicode.com
首页 > Web开发 > 详细

php 获取开始日期与结束日期之间所有日期

时间:2018-05-26 14:03:19      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:int   while   span   style   color   []   start   func   return   

话不多说,源码奉上!

function getDateRange($startdate, $enddate) {
    $stime = strtotime($startdate);
    $etime = strtotime($enddate);
    $datearr = [];
    while ($stime <= $etime) {
        $datearr[] = date(‘Y-m-d‘, $stime);//得到dataarr的日期数组。
        $stime = $stime + 86400;
    }
    return $datearr;
}

$dates=getDateRange(‘2016-1-1‘,‘2016-1-6‘);
print_r($dates);

 

php 获取开始日期与结束日期之间所有日期

标签:int   while   span   style   color   []   start   func   return   

原文地址:https://www.cnblogs.com/blibli/p/9092653.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!