nameless
nameless

Reputation: 1521

fullcalendar - enddate not correct

I have a fullcalendar, and I'm able to enter event's in it. But, when I enter events, without a time, they appear to end one day earlier, so when I have the end-date of 2015-09-05, it ends on the 4th. of September, not on the 5th... I think it's because it's "the end", so on that day, it's over, so it ends one day before, but I don't want that behaviour, I want to have it shown, like the day you provide for the end is still in the time the event "runs". The interesting thing is, that if I provide a time (like 2015-09-05T14:00:00), it works, because it definetely ends on the provided day.

The question now is: How can I change this behaviour, so the event is displayed with the right time?

edit: the problem is really, that the day you provide, is exclusive, so it's not in the time any more.

end :The exclusive date/time an event ends. Optional.

The question is, how can I change this behaviour...

edit2 I tried something like

var end_split = enddate.split('-');
end_split[2]= parseInt(end_split[2])+parseInt("1");
enddate = end_split[0] + "-" + end_split[1] + "-" + end_split[2];

this now, and it works in general, but has issues, if enddate is the 30th of a month, because then the end date saved will be the 31th, and this doesn't exist always...., so this solution won't work...

Upvotes: 2

Views: 2595

Answers (2)

Shafiq
Shafiq

Reputation: 1023

I was also facing the same and resolved it by adding "T23:59:00" with the end date PHP code:

$data_events[] = array(
             "id" => $eventid,
             "title" => $title,              
             "start" => $start_date,                 
             "end" => $end_date."T23:59:00"
         );     
echo json_encode(array("events" => $data_events));

Upvotes: 1

user5292425
user5292425

Reputation:

The answer is simple if we follow the following steps

  1. get the end time from the user as string
  2. convert it to milliseconds using milliseconds = Date.parse(enddate);
  3. Add number of milliseconds corresponding to 24 hrs with milliseconds variable
  4. then change it as a date object using var d = new Date(milliseconds);
  5. convert it to your desired format using Moment.js
  6. at last send it to your php script using ajax

Upvotes: 3

Related Questions