Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full Calendar Time interval Should be 1 hour and start from 6:30

I tried this implementation Full Calendar Implementation.

    $("#available_classes_calendar").fullCalendar({
        header: {
             left   : 'prev,next',
             center : 'title'
            },
        defaultView: 'agendaWeek',
        views:{
            agenda:{
                allDaySlot: false,
                minTime: "06:30:00",
                maxTime: "24:00:00",
                slotDuration: "00:60:00"
            }
        }
    });

In this all-day column should be start from 6:30am and interval slot should be 1 hour.

So all-days column should look like:

6:30 am 7:30 am 8:30 am . . . 11:30 pm

I tried lots of solution but not able to achieve this.

Please let me know if any other info is required to solve this.

Thanks Screenshot from @lucasnadalutti fiddle

like image 593
Pardeep Dhingra Avatar asked May 25 '15 18:05

Pardeep Dhingra


People also ask

Is full calendar an API?

FullCalendar provides settings, methods, and callbacks for interacting with and switching the current view. The initial view when the calendar loads. A View object contains information about a calendar view, such as title and date range.

What is FullCalendar?

What is Fullcalendar? FullCalendar is a JavaScript library that seamlessly integrates with such popular JavaScript frameworks as Vue, React, Angular.

What is a duration in full calendar?

A duration is a way to express an amount of time that has passed. It can also be used to express a time-of-day, in other words, the amount of time that has passed since the start of the day. FullCalendar’s API accepts durations at various points, such as slotDuration. It can be specified in one of three ways:

What is the most common calendar interval in outlook?

Outlook for Microsoft 365 Outlook 2019 Outlook 2016 Outlook 2013 Outlook 2010 Although the most common calendar intervals are 15 minutes and 30 minutes, you can also change the time scale interval of your calendar to 5, 6, 10, or 60 minutes.

How many hours are there in a day?

An hour is most commonly defined as a period of time equal to 60 minutes, where a minute is equal to 60 seconds, and a second has a rigorous scientific definition. There are also 24 hours in a day. Most people read time using either a 12-hour clock or a 24-hour clock. 12-hour clock:

How do I change the time scale interval of my calendar?

Although the most common calendar intervals are 15 minutes and 30 minutes, you can also change the time scale interval of your calendar to 5, 6, 10, or 60 minutes. In Calendar, on the View tab, in the Arrangement group, click Time Scale, and then click the grid interval that you want to show in the calendar.


2 Answers

Your issue is the place where you've put your options. It should be

$("#available_classes_calendar").fullCalendar({
    header: {
         left   : 'prev,next',
         center : 'title'
        },
    defaultView: 'agendaWeek',
    allDaySlot: false,
    minTime: "06:30:00",
    maxTime: "24:00:00",
    slotDuration: "06:00:01"
});

Regarding the display of 06:30, 07:30 and so on, on the vertical axis, you need to set the slotDuration: "06:30:01". Take a look at this jsfiddle.

The most important thing to notice is the 01 second on the slotDuration. Without this, you won't be able to display half hours.


Explanation as to why you need the "+01" second:

FullCalendar supports axis with half hours or whatever you want, but you need to do this quirky thing. The reason behind this is in the source code itself (view source for FullCalendar 2.3.1), from line 5714 to 5719:

((!slotNormal || !minutes) ? // if irregular slot duration, or on the hour, then display the time
    '<span>' + // for matchCellWidths
        htmlEscape(slotDate.format(this.axisFormat)) +
    '</span>' :
    ''

Now, $slotNormal is defined on line 5701 and is:

var slotNormal = this.slotDuration.asMinutes() % 15 === 0;

So, if you have a 30 minute slot time, the condition will be false and FullCalendar won't display the time. This subject is covered in depth in this answer.

One additional remark: You're using FullCalendar v1.5.4 which is really old and I advice you to upgrade. If you do upgrade, remember that FullCalendar now relies on momentjs.

like image 188
Luís Cruz Avatar answered Nov 06 '22 08:11

Luís Cruz


Simply pull out the options that you put inside views.

This is your modified working fiddle.

like image 21
lucasnadalutti Avatar answered Nov 06 '22 08:11

lucasnadalutti