3

我一直在使用标准的 ISO 日期时间格式来插入完整的日历。测试时,即使 allDay 字段设置为 false,我也无法将时间输入日历。以下是我的php代码。

$eventdt = date_format($eventdate,'c');
$eventet = date_format($eventend,'c'); 
 $buildjson = array('id'=>"$eventtest",'title' => "$eventtest", 'start' => "$eventdt", 'end' => "$eventet", 'allDay' => 'false', 'backgroundColor' => "$eventc");
array_push($jsonArray, $buildjson);
echo json_encode($jsonArray);

这段代码的输出是

[{"id":"106","title":"106","start":"2013-07-17T11:00:00+02:00","end":"2013-07-18T14:00:00+02:00","allDay":"false","backgroundColor":"#FF0000"},{"id":"107","title":"107","start":"2013-07-19T10:45:00+02:00","end":"2013-07-20T14:15:00+02:00","allDay":"false","backgroundColor":"#FF0000"},{"id":"108","title":"108","start":"2013-07-22T10:45:00+02:00","end":"2013-07-22T14:15:00+02:00","allDay":"false","backgroundColor":"#FF0000"},{"id":"109","title":"109","start":"2013-07-22T10:45:00+02:00","end":"2013-07-22T14:15:00+02:00","allDay":"false","backgroundColor":"#D7DF01"}]

我看到 datetime 标签有一个额外的 +2:00 是本地时区。当我尝试在脚本中手动插入值时,时间会反映在日历上

手动插入:

events: [   {
                title: 'class5 meeting',
                start: '2013-07-17T11:00:00',
                end: '2013-07-18T14:00:00',
                allDay: false,
                backgroundColor: '#ff0000'
                }
            ]

有什么方法可以修剪日期并发送所需的值,以便反映这些值?

提前致谢!

4

1 回答 1

2

我认为问题可能是falsePHP 生成的 JSON 中“allDay”字段的值是 aString而 FullCalendar 期望的是Bool.

尝试更改$buildjson如下:

$buildjson = array('id'=>"$eventtest",'title' => "$eventtest", 'start' => "$eventdt", 'end' => "$eventet", 'allDay' => false, 'backgroundColor' => "$eventc");(注意false没有用引号括起来)

于 2013-07-16T14:00:13.537 回答