08月02, 2018

php 生成时间数组

有时候我们需要生成一段时间内的数组,这个时候就需要range()函数来做了

先看代码:


 $time = range(strtotime('2018-04-25'), strtotime('2018-08-02'), 86400);

$dateArray = array_map(function ($value){
        return date('Y-m-d', $value);
 }, $time);

本文链接:http://blog.guansixu.cn/post/php-date-array.html

-- EOF --

Comments