完整日历事件数据显示问题

时间:2017-06-14 06:48:44

标签: php fullcalendar

让我们说我正在制作活动 自日期:2017-06-14 至今:2017-06-16 从时间:13:00:00 到时间:16:00:00

我正确地将这些存储在数据库中。 现在问题在于完整日历数据应该在时间13:00:00到16:00:00之间显示,而不是在2017-06-15显示一整天。 任何错误? 我的代码是

显示数据的完整日历:

public function GetJsonRateInfo($rate_id)
    {
        $json = array();
        $start=$_REQUEST['start'];
        $end=$_REQUEST['end'];
        if($start != '' && $end != '')
        {
            $where="(from_date BETWEEN '$start' and '$end') or (to_date BETWEEN '$start' and '$end')";
            $finalArray=[];
            $json=$this->Rates_model->getAnyData($where);
            /*echo '<pre>';
            print_r($json);
            die();*/
            if(!empty($json))
            {

                foreach ($json as $key => $js) {

                    $finalArray[$key]['id']= $js->id;

                    $finalArray[$key]['start']= date('Y-m-d',strtotime($js->from_date))."T".$js->from_time;
                    $finalArray[$key]['end'] = date('Y-m-d',strtotime($js->to_date))."T".$js->to_time;

                    if(!empty($js->rate_per_hour) && !empty($js->rate_per_mile))
                    {
                        $fullTitle="Per Hour: ".$js->rate_per_hour.",Per Mile: ".$js->rate_per_mile;
                    }
                    elseif(!empty($js->rate_per_hour) && empty($js->rate_per_mile)){
                        $fullTitle="Per Hour: ".$js->rate_per_hour;
                    }
                    elseif(empty($js->rate_per_hour) && !empty($js->rate_per_mile)){
                       $fullTitle="Per Mile: ".$js->rate_per_mile;
                    }
                    $finalArray[$key]['title']=$fullTitle;
                }

                echo json_encode($finalArray);
            }
        }

    }

获取数据功能

[{"id":"1","start":"2017-06-14T13:00:00","end":"2017-06-15T16:00:00","title":"Per Hour: 11.00,Per Mile: 11.00"}]

我的Json数据:

#!/bin/bash
Num=0
arr=( $(find . -name '*.mat' | sort) )

for i in "${arr[@]}"
do

  file=$(basename "${i}")

  while read -r line
  do

  name="$line"
  IFS=' ' read -r -a array <<< "$line"
    for index in "${!array[@]}"
    do

      if [ ${array[index]} == "MAT1" ]
      then
        out[$num] = "${array[index+1]} $file "
        let num++
        #printf "%-32s %8i\n" "$file" "${array[index+1]}"
      fi

    done

  done < "$i"

done

1 个答案:

答案 0 :(得分:1)

在您的示例中,您有一个事件,从14日13:00开始,到15日16:00结束。因此,事件(1天+ 3小时)之间的所有时间都将被事件覆盖。这是日历中完全正确的行为 - 请参阅此处:https://jsfiddle.net/4bznpxc5/1

如果您想在3个不同的日子重复相同的时间,则必须在JSON Feed中输出3个单独的事件对象,如下所示:

[
  {"id":"1","start":"2017-06-14T13:00:00","end":"2017-06-14T1‌​6:00:00","title":"Pe‌​r Hour: 11.00,Per Mile: 11.00"},
  {"id":"2","start":"2017-06-15T13:00:00","end":"2017-06-15T16‌​:00:00","title":"Per Hour: 11.00,Per Mile: 11.00"},
  {"id":"3","start":"2017-06-16T13:00:00","end":"2017-06-16T16‌​:00:00","title":"Per Hour: 11.00,Per Mile: 11.00"}
]