PHP7一年中每个月的月初和月末时间戳

发布时间:2020-06-19 18:48:18 作者:努力的C
来源:网络 阅读:912

每个月的月初和月末
我是在2019年1月要帮助运营统计2018年每个月的一些数据。因为需要按月统计,所以这里记录一下。基本上用到的就是strtomtime的一些特性。first day of month last day of month

$index = 0;
$like = 0;
for ($i = 12; $i>0; $i--) {
    $like = 0;
    $commt = 0;
    $start = strtotime('first day of -'.$i.' month');
    $end = strtotime('last day of -'.$i.' month');
    $fstart = strtotime(date('Ymd 00:00:00', $start));
    $fend = strtotime(date('Ymd 23:59:59', $end));
    echo (13-$i)."月起始日期".PHP_EOL;
    echo $fstart.'===>'.date('Ymd 00:00:00', $start).PHP_EOL;
    echo $fend.'====>'.date('Ymd 23:59:59', $end).PHP_EOL;
    }
    echo (13-$i)."月评论总数".$commt.PHP_EOL;

}
推荐阅读:
  1. 获取这个指定日期的上月的月初和月末时间
  2. 用php获取指定月份月初和月末时间戳的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php7 strtotime 月初月末时间戳

上一篇:一招实现“微信直接下载APK”+“社交平台一键拉起”

下一篇:Monitor DRBD devices with nagios

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》