Problems with Jquery Fullcalendar dates

Asked

Viewed 476 times

1

I’m having trouble with the save dates at the bank. In order for me to save the date it should come like this:

2017-01-09 19:39:12

But she’s coming like this:

Thu Jan 05 2017 00:00:00 GMT+0000

The setting of my fullcallendar is like this:

    $('#calendar').fullCalendar({
        // put your options and callbacks here
        selectable: true,
        editable: true,
        select: function(start, end, allDay) {
          $("#addEvent").show();
          $("#editEvent").hide();
          $("#addNew-event").modal("show");
          $("#addNew-event input:text").val("");
          $("#getStart").val(start);
          $("#getEnt").val(end);
      },
      eventClick: function(event, element) {
          $("#addEvent").hide()
          $("#editEvent").show().data("ev", event);
          $("#addNew-event").modal("show");
          $("#addNew-event input:text").val("");
          $("#eventName").val(event.title);
      }
  });

What should I do to make these dates effective as I need to save in the bank ?

The problem is when I need to reload the data in the API. Because then it needs to accept the normal format saved in the database.

What to do ?

1 answer

0

I believe the solution is to use the format of Moment.js.

$('#calendar').fullCalendar({
    ...
    select: function(start, end, allDay) {
      ...
      $("#getStart").val(moment(start).format("YYYY-MM-DD HH:mm"));
      $("#getEnt").val(moment(end).format("YYYY-MM-DD HH:mm"));
  }
...
});

There are still other ways to format the date.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.