PHP日历期(每周)

时间:2015-08-03 07:50:59

标签: javascript php calendar period

我正在制作日历,现在我已经在活动的周末堆积了。我不能这样做,它有效,但仅适用于下个月和其他月份。

$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-&gt; day是期间的一天,$ array ['month']现在列出月份,$ array ['year']现在列出年份。函数numDays返回0-6取决于它在哪一天。谢谢。它必须隐藏在HTML 5日历中。

没关系,它在St列中,下个月是相同的,但是接下来的2个月它在列Čt。

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

好的,我做了解决方案,首先是获得期间的开始日期

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

在此之后我设置第一天的变量,即1.它将转到cyclus,因此它是0.在添加此变量后,我每天循环循环并检查实际的日期是星期三还是星期二等....

$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;
                                }
                            }


                        }