Неправильный месяц в полном календаре - PullRequest
1 голос
/ 09 декабря 2010

Я встроил элемент управления 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 оповещения в этом коде. Отображается дата ср. 14 декабря 2010 00:00:00 GMT + 0530 (индийское стандартное время) , что не так. Но если я выберу месяц этой даты, он должен показать мне 12, а точнее 11. почему это должно быть?

Я проверил свою системную дату. Урегулировано на текущую дату. так что не должно быть вопроса.

1 Ответ

2 голосов
/ 09 декабря 2010

1001 * попробовать *

date.getMonth()+1 instead of date.getMonth()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...