dongtao9887 2017-01-01 16:58
浏览 47

星期三的日历,但1月失踪

I tried to write a Wednesday calendar, the calendar should only show the Wednesday in a table, and it should be able to write a meeting in the calendar

I tried to change:

strotime('-1 month')

But then it shows no calendar.

function getMittwoch($y, $m)
{
    return new DatePeriod(
        new DateTime("first wednesday of $y-$m"),
        DateInterval::createFromDateString('next wednesday'),
        new DateTime("last day of $y-$m")
    );
}

So last year, it functioned, but now not. The calendar shows only February till December, but the January is missing.

for( $monat=date('m', strtotime('0 month'))+1; $monat<13; $monat++ ){
        foreach (getMittwoch(date('Y'), $monat) as $mittwoch) {
            $tagWert = $mittwoch->format("dmY");

What should I change for 2017?

  • 写回答

3条回答 默认 最新

  • duanchou6534 2017-01-01 21:51
    关注

    my script will find all wednesdays in given date:

    function getWednesday($y,$m){
        $inmonth=date('t', mktime(0, 0, 0, $m, 1, $y)); ;
    
        for($i=0;$i<$inmonth;$i++){
            $d=$i+1;
            $timestamp = strtotime("$y-$m-$d");
            $day = date('w', $timestamp);
            if($day==3){
                echo "Wednesday found - $y-$m-$d<br>";
            }
        }
    }
    
    getWednesday(2017,1);
    

    Output is:

    Wednesday found - 2017-1-4
    Wednesday found - 2017-1-11
    Wednesday found - 2017-1-18
    Wednesday found - 2017-1-25
    

    You can replace the echo with something else of course. I hope it will help you.

    Ondrej

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集