dongyoucha0645 2015-08-03 07:50
浏览 38

PHP日历期(每周)

I doing calendar and I'm now stacked on week period of event. I can't do that, it works, but only for next month and others months not.

$i = 1; 

            $den = $post->day;
            $mesic = $array['month'];
            $rok = $array['year'];
            $minusDays = $this->numDays(date('l', $den.".".$mesi.".".$rok));
            $startedWeek = date('W', strtotime($den.".".$post->month.".".$post->year));
            $actualWeek  = date('W', Time());

            $startedWeek = $actualWeek - $startedWeek;


            for($i; $i<6; $i++){
                if($i==1){
                $startedWeek = $startedWeek;
            }else{
                $startedWeek = $startedWeek+1;
            }
                $plusDay = date('j', strtotime($den.".".$mesic.".".$rok." + ".$startedWeek." weeks - ".$minusDays." days"));
                $plusWeek = date('n',strtotime($den.".".$mesic.".".$rok." + ".$startedWeek." weeks - ".$minusDays." days"));
                $plusYear = date('Y',strtotime($den.".".$mesic.".".$rok." + ".$startedWeek." weeks - ".$minusDays." days"));

                       echo "<input type='hidden' class='interval' data-id='".$post->id."' data-name='".$post->name."' data-d='".$plusDay."' data-day='".$plusDay."' 
                       data-before='".$post->remindBefore."' data-unit='".$post->remindBeforeUnit."' data-remindBy='".$post->remindBy."' data-remindInterval='".$post->remindInterval."' 
                       data-eventTimeH='".$post->remindH."' data-eventTimeM='".$post->remindM."'>";             
                                }

$post->day is day of period, $array['month'] is now listed month, $array['year'] is now listed year. Function numDays returning 0-6 deppends on what day is it. Thank you. It must be in hidden becouse HTML 5 calendar.

There is it ok, it is in column St, next month is same, but 2 months next it is in column Čt.

enter image description here

enter image description here

  • 写回答

1条回答 默认 最新

  • dougu3988 2015-08-03 08:56
    关注

    Ok i did solution, first is to get startDate of period

    $dayOfWeek = date('w', strtotime($post->day.".".$post->month.".".$post->year)); // day of week to start period 
    

    after this i set variable of first day, which is 1. It will go to cyclus so it is 0. After added this variable i loop in cycle every day and check if actual day is Wednesday or Tuesday etc....

    $dd=0;
    
                            for($i=1; $i<7; $i++){
    
                                for($c=0; $c<7; $c++){
                                    $dd++;
                                    $actualDayOfWeek = date('w', strtotime($dd.".".$array['month'].".".$array['year']));
                                    $plusDay = date('j', strtotime($dd.".".$array['month'].".".$array['year']));
                                    if($dayOfWeek != $actualDayOfWeek){
                                    }else{
    
                                        $actualDayOfWeek = date('w', strtotime($dd.".".$array['month'].".".$array['year']));
                                        $plusDay = date('j', strtotime($dd.".".$array['month'].".".$array['year']));
                                        echo "<input type='hidden' class='interval' data-id='".$post->id."' data-name='".$post->name."' data-d='".$dd."' data-day='".$plusDay."' 
                                      data-before='".$post->remindBefore."' data-unit='".$post->remindBeforeUnit."' data-remindBy='".$post->remindBy."' data-remindInterval='".$post->remindInterval."' 
                                      data-eventTimeH='".$post->remindH."' data-eventTimeM='".$post->remindM."'>";  
                                        break;
                                    }
                                }
    
    
                            }
    
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!