问题描述
不知何故,我做错了。我在 Fullcalendar
时间区域被绊倒了。我已经尝试将 ignoreTimezone
设置为true和false,但似乎并不重要。这是在两个地方的代码,因为我不确定它从哪里去。 我的数据源是一个隐藏的表单字段。通过添加5小时(CDT)来调整 FullCalendar
的 out 的数据。删除5小时不会调整到 FullCalendar
中 的数据。
在后端,我只是保存并返回JSON字符串而不处理它(或者甚至解码它)
页面加载:
pre>
数据输入:空,无数据
数据编辑:从中午拖到下午2点(CDT),然后提交表单
数据输出:使用clientEvent获取数据,并将JSON.stringify投入表单领域。
[{id:6844,title:Open,start:2011-04-19T17:00:00.000Z,end:2011-04-19T19:00: 00.000Z,allDay:false}]
页面加载(提交表单后):
数据输入:使用JSON.parse从隐藏表单域加载数据。这是传入的数据,但事件转移到控制中的下午5点(CDT)。
[{id:6844,title:Open,start:2011-04-19T17:00:00.000Z,end:2011-04-19T19:00: 00.000Z,allDay:false}]
数据输出:不改变控制,现在是:
[{id:6844,title:Open,start: 2011-04-19T22:00:00.000Z,end:2011-04-20T00:00:00.000Z,allDay:false}]
我这样设置
Fullcalendar
:// Fullcalendar for business hours page
jQuery(document).ready(function(){
jQuery('#edit-提交')。bind(click,business_hours_set);
jQuery('#edit-preview')。bind(click,business_hours_set);
jQuery('#calendar' ).fullCalendar({
//配置显示
标题:{
left:'',
center:'',
right:''
},
ignoreTimezone:false,
defaultView:'agendaweek',
allDaySlot:false,
firstHour:8,
//配置选择创建事件
selectable:true,
selectHelper:true,
select:business_hours_add,
//配置数据源
可编辑:true,
eventSources:[
{
events:jQuery.parseJSON(jQuery('#fullcalendar_data').val()),
color:'#992B0A',
textColor: 'white',
ignoreTimezone:false
}
],
//配置编辑
eventClick:function(calEvent){
business_hours_delete (calEvent.id);
}
});
alert(jQuery('#fullcalendar_data')。val());
});
函数business_hours_add(startDate,endDate){
var calendar = jQuery('#calendar');
var newid = Math.ceil(Math.random()* 64000);
calendar.fullCalendar('renderEvent',
{
id:newid,
title:Open,
start:startDate,
end:endDate ,
allDay:false
},
true //使事件stick
);
calendar.fullCalendar('unselect');
}
var business_hours_selectedId = -1;
函数business_hours_delete(id){
business_hours_selectedId = id;
jQuery(#dialog-confirm).dialog({
resizable:false,
height:160,
modal:true,
buttons :{
是,删除!:function(){
calendar = jQuery('#calendar');
calendar.fullCalendar('removeEvents',business_hours_selectedId);
jQuery(this).dialog(close);
},
取消:function(){
jQuery(this).dialog(close);
}
}
},id);
function business_hours_set(){
var data = jQuery('#calendar')。fullCalendar('clientEvents');
//数据是周期性的。创建一个新的数据结构以进行串联化。
var ret = [];
for(var i = 0; i< data.length; i ++){
var datum = {
id:data [i] .id,
title:data [i ] .title,
start:data [i] .start,
end:data [i] .end,
allDay:data [i] .allDay
}
ret [i] =基准;
}
// stringify并返回
jQuery('#fullcalendar_data').val(JSON.stringify(ret));
alert(JSON.stringify(ret));
}
我做错了什么?
在此先感谢,Mike
解决方案我在FullCalendar中拥有相同的时间转换。
在服务器上查看您的时区,当我将其更改为我自己的时区时,它可以帮助我。
您可以尝试以下几种方式:
在服务器上:
或者在PHP脚本中(返回JSON字符串):
PS
不要忘记将欧洲/莫斯科更改为您的值: - )
然后,您必须在新时区中设置有效时间(日期命令);
I'm doing it wrong somehow. I'm getting tripped up on timezones with
Fullcalendar
. I've tried settingignoreTimezone
to true and false, but it doesn't seem to matter. It's in the code below in two places because I wasn't sure from the doc where it goes.My data source is a hidden form field. Data that goes out of
FullCalendar
is adjusted by adding 5 hours (CDT). Data that goes in toFullCalendar
isn't adjusted by removing 5 hours.On the back-end, I'm just saving and returning the JSON string without processing it (or even decoding it)
Page Load: Data In: Empty, no data Data Edit: drag from noon to 2pm (CDT), then submit form Data Out: Use clientEvent to get data, and JSON.stringify to put into form field. [{"id":6844,"title":"Open","start":"2011-04-19T17:00:00.000Z","end":"2011-04-19T19:00:00.000Z","allDay":false}] Page Load (after submitting form): Data In: Use JSON.parse to load data from hidden form field. This is the incoming data, but the event is shifted to 5pm (CDT) in the control. [{"id":6844,"title":"Open","start":"2011-04-19T17:00:00.000Z","end":"2011-04-19T19:00:00.000Z","allDay":false}] Data Out: Without changing the control, it's now: [{"id":6844,"title":"Open","start":"2011-04-19T22:00:00.000Z","end":"2011-04-20T00:00:00.000Z","allDay":false}]
I setup the
Fullcalendar
like this:// Fullcalendar for business hours page jQuery(document).ready(function() { jQuery('#edit-submit').bind("click", business_hours_set); jQuery('#edit-preview').bind("click", business_hours_set); jQuery('#calendar').fullCalendar({ // configure display header: { left: '', center: '', right: '' }, ignoreTimezone: false, defaultView: 'agendaWeek', allDaySlot: false, firstHour: 8, // configure selection for event creation selectable: true, selectHelper: true, select: business_hours_add, // configure data source editable: true, eventSources: [ { events: jQuery.parseJSON(jQuery('#fullcalendar_data').val()), color: '#992B0A', textColor: 'white', ignoreTimezone: false } ], // configure editing eventClick: function(calEvent) { business_hours_delete(calEvent.id); } }); alert(jQuery('#fullcalendar_data').val()); }); function business_hours_add(startDate, endDate) { var calendar = jQuery('#calendar'); var newid = Math.ceil(Math.random()*64000); calendar.fullCalendar('renderEvent', { id: newid, title: "Open", start: startDate, end: endDate, allDay: false }, true // make the event "stick" ); calendar.fullCalendar('unselect'); } var business_hours_selectedId = -1; function business_hours_delete(id) { business_hours_selectedId = id; jQuery( "#dialog-confirm" ).dialog({ resizable: false, height:160, modal: true, buttons: { "Yes, delete!": function() { calendar = jQuery('#calendar'); calendar.fullCalendar( 'removeEvents', business_hours_selectedId); jQuery( this ).dialog( "close" ); }, Cancel: function() { jQuery( this ).dialog( "close" ); } } }, id); } function business_hours_set() { var data = jQuery('#calendar').fullCalendar( 'clientEvents' ); // data is cyclical. Create a new data structure to stringify. var ret = []; for(var i=0; i<data.length; i++) { var datum = { id: data[i].id, title: data[i].title, start: data[i].start, end: data[i].end, allDay: data[i].allDay } ret[i] = datum; } // stringify and return jQuery('#fullcalendar_data').val(JSON.stringify(ret)); alert(JSON.stringify(ret)); }
What am I doing wrong?
Thanks in advance, Mike
解决方案I had the same timeshift in FullCalendar.Check out your timezone on server, when I changed it to my own it help me.You may try to do it in few ways:
On serer:
Or in PHP script (which returns JSON string):
P.S.Don't forget to change "Europe/Moscow" to your values :-)
Then you have to set your valid time in new time zone ("date" command);
这篇关于Fullcalendar和时区。帮助,我做错了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!