Getting wrong month in fullcalendar control
I have embedded the fullcalendar jquery control by using this code:
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var officerid = document.getElementById('officerid').value;
url = "/TasksToOfficer/Calender/" + officerid;
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay',
border: 0
},
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
var title = prompt('Event Title:', { buttons: { Ok: true, Cancel: false }
});
if (title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true);
var date = new Date(start);
var dateString = (date.getDate()) + '/' + date.getMonth() + '/' + date.getFullYear();
alert("Date:" + date);
alert("Only Date:"+date.getDate());
alert("Month" + date.getMonth());
alert("Year" + date.getFullYear());
if (officerid) {
$.ajax(
{
type: "POST",
url: "/TasksToOfficer/Create",
data: "officerid=" + officerid + "&description=" + title + "&date=" + dateString,
开发者_如何学C success: function(result) {
if (result.success) $("#feedback input").attr("value", ""); // clear all the input fields on success
$("#feedback_status").slideDown(250).text(result.message); // show status message with animation
},
error: function(req, status, error) {
}
});
}
}
calendar.fullCalendar('unselect');
},
editable: true,
events: url
});
});
But as I am getting values of date while saving ,it is shiwing wrong. Let say I have use 4 alerts in this code. It showing , Date as Wed Dec 14 2010 00:00:00 GMT+0530(Indian standard Time) , which is not wrong. But if I go for pick the month of this date it must show me 12 , rather it showing me 11 . why this should be ?
I have checked my system date. It is settle to current date. so that should not be issue.
try
date.getMonth()+1 instead of date.getMonth()
精彩评论