Home > database >  how to change start and end time show in fullcalendar?
how to change start and end time show in fullcalendar?

Time:04-11

I am trying to change start time and end time on FullCalendar like to start calendar at 8:00 and finish at 18:00

code:

document.addEventListener('DOMContentLoaded', function() {
  var calendarEl = document.getElementById('calendar');

  var calendar = new FullCalendar.Calendar(calendarEl, {
    initialView: 'timeGridWeek',
    businessHours:{
    dow: [ 1, 2, 3 ], 
    start: '08:00', 
    end: '18:00'
  },
  });

  calendar.render();
});
html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  font-size: 14px;
}

#calendar {
  max-width: 1100px;
  margin: 40px auto;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/main.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/main.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id='calendar'></div>

CodePudding user response:

You are searching for slotMinTime and slotMaxTime

https://fullcalendar.io/docs/timegrid-view

document.addEventListener('DOMContentLoaded', function() {
  var calendarEl = document.getElementById('calendar');

  var calendar = new FullCalendar.Calendar(calendarEl, {
    initialView: 'timeGridWeek',
    slotMinTime: '08:00:00',
    slotMaxTime: '18:00:00',
    expandRows: true,
    businessHours: {
      dow: [1, 2, 3],
    },
  });

  calendar.render();
});
html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  font-size: 14px;
}

#calendar {
  max-width: 1100px;
  margin: 40px auto;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/main.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/main.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id='calendar'></div>

  • Related