LittPi
LittPi

Reputation: 13

Add End Time for FullCalendar's Week and Daily View

I am using FullCalendar v2 now and I found it is quite useful. However, I have encountered a problem when I want to show the end time of an event.

I want to show both start time and end time within a day in week and daily view like "09:00-17:00". I have found a solution in Display ending time in fullcalendar week view only but it seems a v1 version. I use this in v2 and failed.

How can I show both start time and end time within a day?

Upvotes: 0

Views: 1504

Answers (3)

Ben Jenkinson
Ben Jenkinson

Reputation: 1834

I found that this answer worked for me: https://stackoverflow.com/a/24951989/590382


In FullCalendar >= 2.0.1, there is a setting called displayEventEnd.

Documentation: http://fullcalendar.io/docs/text/displayEventEnd/

Whether or not to display an event's end time text when it is rendered on the calendar.

Example:

displayEventEnd: {
    month: false,
    basicWeek: true,
    "default": true
}

Upvotes: 2

mesosteros
mesosteros

Reputation: 1519

No need for such a convuluted answer as the one above. I had the same issue and I fixed it by simply configure the fullcalendar properties as so:

timeFormat: {
            month: "HH:mm",
            week: "HH:mm",
            day: "HH:mm"
        },

Upvotes: 0

baronmog
baronmog

Reputation: 48

The answer here: Fullcalendar event's end time is missing works for version 1.6.1. However, the formatDates function has been replaced by formatRange in v2. So, use

eventAfterRender: function(event, $el, view) {
        var formattedTime = $.fullCalendar.formatRange(event.start, event.end, "HH:mm");
        // If FullCalendar has removed the title div, then add the title to the time div like FullCalendar would do
        if($el.find(".fc-event-title").length === 0) {
            $el.find(".fc-event-time").text(formattedTime + " - " + event.title);
        }
        else {
            $el.find(".fc-event-time").text(formattedTime);
        }
    }

Upvotes: 0

Related Questions