使用PHP如何获取某个月的所有日期列表

 
更多

使用PHP如何获取某个月的所有日期列表。

/**
 * 获取某月所有时间列表
 * @param string $time 某天时间戳
 * @param string $format 转换的时间格式
 * @return array
 */
function get_month_day_list($time = '', $format = 'Y-m-d') {
    $time = $time != '' ? $time : time();
    //获取当前周几
    $week = date('d', $time);
    $date = [];
    for ($i = 1; $i <= date('t', $time); $i++) {
        $date[$i] = date($format, strtotime('+' . $i - $week . ' days', $time));
    }
    return $date;
}
打赏

本文固定链接: https://www.cxy163.net/archives/3270 | 绝缘体

该日志由 绝缘体.. 于 2020年04月26日 发表在 未分类 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: 使用PHP如何获取某个月的所有日期列表 | 绝缘体
关键字: , , , ,

使用PHP如何获取某个月的所有日期列表:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter