首页 > 其他 > 详细

用strtotime()和date()函数算出2019年9月的周日日期

时间:2019-09-21 10:59:49      阅读:99      评论:0      收藏:0      [点我收藏+]
  • strtotime
<?php
$firstsunday = strtotime(date(Y-m-01));
$thisy = intval(date(m));
$diffdays=0;
$count = 0;
if (date(w,strtotime(date(Y-m-01)))!=0)
{
      $diffdays=7-date(w,strtotime(date(Y-m-01)));
}
else{
    $count++;
}
$startdate =strtotime(date(Y-m-01)."+".$diffdays."day");
while (True)
{
    if ($thisy!=intval(date(m,$startdate)))
    {
            break;
    }
    echo date(Y-m-d,$startdate)."\n";
    $startdate = strtotime(date(Y-m-d,strtotime(date(Y-m-d,$startdate)."+7 day")));
    //
}

结果

2019-09-01
2019-09-08
2019-09-15
2019-09-22
2019-09-29

 

用strtotime()和date()函数算出2019年9月的周日日期

原文:https://www.cnblogs.com/saintdingspage/p/11561246.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!