博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php 时间统计处理
阅读量:3727 次
发布时间:2019-05-22

本文共 1012 字,大约阅读时间需要 3 分钟。

/**     * @param $month     * @return string     * 指定年月份获取月初月末的时间戳     */    public function getTime($month)    {        $month_start = strtotime($month);//指定年月份月初时间戳        $BeginDate = date('Y-m-01', strtotime($month));        $EndDate = date('Y-m-d', strtotime("$BeginDate +1 month -1 day"));        $month_end = strtotime("next day", strtotime($EndDate)) - 1;//指定年月份月末时间戳        $months = $month_start . ' and ' . $month_end;        return $months;    }

获取从2017-01到现在所有的月份

$start_time = "2017-01";        $strtotime_start_time = strtotime($start_time);        $lastMonth = strtotime(date("Y-m", time()));        $monthArr = [];        for ($i = 1; $lastMonth > $strtotime_start_time; $i++) {            $lastMonths =  strtotime(date('Y-m') . '-01 00:00:01');            $t = "-". $i ." month";            $lastMonths = date('Y-m', strtotime($t, $lastMonths));            var_dump(strtotime($lastMonths));            array_push($monthArr, $lastMonths);            $lastMonth = strtotime($lastMonths);        }

 

转载地址:http://qqtnn.baihongyu.com/

你可能感兴趣的文章
在CentOS 中安装Docker
查看>>
CentOS配置Docker阿里云镜像加速
查看>>
Win10下配置vue环境
查看>>
docker下安装mysql5.7并配置
查看>>
docker容器下安装redis
查看>>
Quotes on Learing(求知若渴)
查看>>
html实现网页左下角音乐播放器
查看>>
用鸿蒙系统跑hello world
查看>>
Springboot+vue前后端项目的部署和搭建
查看>>
python学习笔记一
查看>>
爬虫学习之requests库学习笔记
查看>>
服务器上宝塔linux面板的搭建以及typecho博客的搭建
查看>>
解决前端使用ajax跨域问题
查看>>
Vue之Vue的初体验
查看>>
Vue之插值操作
查看>>
Vue之动态绑定属性
查看>>
Vue之v-on的使用
查看>>
Vue的条件判断和循环遍历
查看>>
Webpack入门
查看>>
使用IDEA创建spring boot项目
查看>>