格式化日期时完整日历弄乱了我的时区
Full Calendar messing with my timezone when formatting date
我正在实施完整日历 -
我的 .js 文件看起来像这样 -
$('#calendar').fullCalendar({
header : {
left:"prev,next today",
center:"title",
right:"agendaWeek,agendaDay"
},
timezone: 'Asia/Kolkata',
defaultView: 'agendaWeek',
allDaySlot: false,
editable: true,
droppable: true,
selectable: true,
selectHelper: true,
eventSources: [{
type: "POST",
url: 'cal_func.php',
async: false,
data: {action:'get_slots', userid:$userxid, which:$calaction},
success: function(data){
if(data.length != 0){
return data;
}else{
}
}
}],
select: function(start, end){
if(parseInt($('#mentor').val()) == 1){
setNotifyMsg('');
}else{
if($calaction == 1){
var startDate = start.format("YYYY-MM-DD HH:MM:SS");
var endDate = end.format("YYYY-MM-DD HH:MM:SS");
$title = $('#titleVal').val();
var out = addAptToDB($title, startDate, endDate, 0);
if(out == 1){
//$('#calendar').fullCalendar('renderEvent',{title: $title, start: start, end: end},true);
$('#calendar').fullCalendar('refetchEvents');
}
}else{
setNotifyMsg('You cannot add an appointment this way.');
}
}
$('#calendar').fullCalendar('unselect');
}
})
现在,当我选择一个时间段来在我的日历中进行预约时,比如说从上午 9 点到上午 10 点。它正在预订上午 9.12 - 10.12 之间的时间段。
我调试了一下,罪魁祸首似乎是'select'-
中的这一行
var startDate = start.format("YYYY-MM-DD HH:MM:SS");
在格式化之前,这是输入-
通过moment.js格式化后,这是输出-
它使用 moment.js 和 returns 错误值的格式。我哪里错了?我该如何解决这个问题。
- 谢谢。
这是因为,MM- 指定了月数。您必须使用正确的格式,例如 'YYYY-MM-DD hh:mm:ss'.
我正在实施完整日历 - 我的 .js 文件看起来像这样 -
$('#calendar').fullCalendar({
header : {
left:"prev,next today",
center:"title",
right:"agendaWeek,agendaDay"
},
timezone: 'Asia/Kolkata',
defaultView: 'agendaWeek',
allDaySlot: false,
editable: true,
droppable: true,
selectable: true,
selectHelper: true,
eventSources: [{
type: "POST",
url: 'cal_func.php',
async: false,
data: {action:'get_slots', userid:$userxid, which:$calaction},
success: function(data){
if(data.length != 0){
return data;
}else{
}
}
}],
select: function(start, end){
if(parseInt($('#mentor').val()) == 1){
setNotifyMsg('');
}else{
if($calaction == 1){
var startDate = start.format("YYYY-MM-DD HH:MM:SS");
var endDate = end.format("YYYY-MM-DD HH:MM:SS");
$title = $('#titleVal').val();
var out = addAptToDB($title, startDate, endDate, 0);
if(out == 1){
//$('#calendar').fullCalendar('renderEvent',{title: $title, start: start, end: end},true);
$('#calendar').fullCalendar('refetchEvents');
}
}else{
setNotifyMsg('You cannot add an appointment this way.');
}
}
$('#calendar').fullCalendar('unselect');
}
})
现在,当我选择一个时间段来在我的日历中进行预约时,比如说从上午 9 点到上午 10 点。它正在预订上午 9.12 - 10.12 之间的时间段。
我调试了一下,罪魁祸首似乎是'select'-
中的这一行var startDate = start.format("YYYY-MM-DD HH:MM:SS");
在格式化之前,这是输入-
通过moment.js格式化后,这是输出-
它使用 moment.js 和 returns 错误值的格式。我哪里错了?我该如何解决这个问题。
- 谢谢。
这是因为,MM- 指定了月数。您必须使用正确的格式,例如 'YYYY-MM-DD hh:mm:ss'.