php循环指定时间段的所有月分开始结束时间戳

来源:赵克立博客 分类: PHP 标签:日期操作发布时间:2018-10-05 14:04:21最后更新:2019-04-22 17:44:42浏览:2106
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2019-04-22 17:44:42
温馨提示:
学无止境,技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章

如下所示循环2018-10(包含)2017年1(包含)每个月的开始和结束时间点

$destime    = strtotime('2017-01-01');
$beginmonth = strtotime('2018-11-01');
while ($beginmonth > $destime) {
    $endmonth   = $beginmonth;
    $beginmonth = strtotime('-1 Month', $beginmonth);
    echo "\n" . date('Y-m-d H:i:s', $beginmonth) . ' - ' . date('Y-m-d H:i:s', $endmonth - 1);
}

效果如下所示

image.png


微信号:kelicom QQ群:215861553 紧急求助须知
Win32/PHP/JS/Android/Python