在fullcalendar控制中出错月份

时间:2010-12-09 06:29:59

标签: jquery fullcalendar

我使用以下代码嵌入了fullcalendar jquery控件:

 $(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,
                                        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
          });
      });

但是因为我在保存的同时获得了约会的价值,所以它错了。假设我在此代码中使用了4个警报。它显示,日期为 2010年12月14日星期三00:00:00 GMT + 0530(印度标准时间),这没有错。但是,如果我选择这个日期的月份它必须显示我12,而不是它显示我11。为什么会这样?

我已查看系统日期。它符合当前日期。所以这不应该是问题。

1 个答案:

答案 0 :(得分:2)

date.getMonth()+1 instead of date.getMonth()
相关问题