PHP获取指定范围内的日期

时间:2021-04-23 12:27:28   收藏:0   阅读:0
//php获取指定范围内的日期
function periodDate($startDate, $endDate)
{
    $startTime = strtotime($startDate);
    $endTime = strtotime($endDate);
    $arr = [];
    while ($startTime <= $endTime)
    {
        $arr[] = date(‘Y-m-d‘, $startTime);
        $startTime = strtotime(‘+1 day‘, $startTime);
    }
    return $arr;
}

#使用
$time = periodDate(‘1912-01-01‘,‘2031-12-31‘);
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!