我一直使用标准的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'
}
]
有什么方法可以修剪日期并发送所需的值,以便反映这些值?
提前致谢!
答案 0 :(得分:2)
我认为问题可能是PHP生成的JSON中'allDay'字段的false
值是String
,而FullCalendar期望Bool
。
尝试更改$buildjson
,如下所示:
$buildjson = array('id'=>"$eventtest",'title' => "$eventtest", 'start' => "$eventdt", 'end' => "$eventet", 'allDay' => false, 'backgroundColor' => "$eventc");
(请注意,false
未包含在引号中)