JavaScript Event calendar Property Reservations

When keeping records of bookings, the event calendar with exact label displays can come in handy. The labels accurately mark the exact start (e.g. 14:00) and end times (e.g. 11:00) of bookings, consolidating all booking records in a single, clear view.

By combining the eventDisplay: 'exact' setting under the view option with customizable renderCalendarEventContent , you can tailor the calendar to your specific needs. This allows you to create an efficient and user-friendly booking planning UI, ensuring all your bookings are easily managed and clearly displayed.

A sidebar at the end of each calendar row summarizes the occupancy of the week. It is added with the renderCalendarSidebarEnd option, while its header cell is customized with the renderCalendarSidebarEndHeader option . The sidebar receives the first and last displayed day of the row together with the events of the row, which are used to calculate the occupancy percentage, the number of booked nights and the number of check-ins for the week. A sidebar can also be added at the start of the rows in the same way.

Download and try example

Demo

Loading the live demo

Preview in full screen

Show property reservations in a monthly booking calendar — exact check-in/check-out time labels, color-coded by platform.

Code

mobiscroll.setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
});

function handleOverlap() {
  mobiscroll.toast({
    message: 'Reservations cannot overlap',
  });
}

var airBnB = 'https://img.mobiscroll.com/demos/air-bnb-icon.png';
var booking = 'https://img.mobiscroll.com/demos/booking-icon.png';
var makeMyTrip = 'https://img.mobiscroll.com/demos/make-my-trip-icon.png';

var myEvents = [
  {
    start: '2026-11-16T12:00',
    end: '2026-11-19T12:00',
    icon: airBnB,
    title: 'Mary Smith',
    color: '#fffa61',
  },
  {
    start: '2026-11-27T12:00',
    end: '2026-12-03T12:00',
    title: 'James Johnson',
    icon: airBnB,
    color: '#fffa61',
  },
  {
    start: '2026-11-22T12:00',
    end: '2026-11-25T12:00',
    title: 'Patricia Williams',
    icon: airBnB,
    color: '#fffa61',
  },
  {
    start: '2026-12-07T12:00',
    end: '2026-12-09T12:00',
    title: 'Michael Brown',
    icon: airBnB,
    color: '#fffa61',
  },
  {
    start: '2026-12-14T12:00',
    end: '2026-12-15T12:00',
    title: 'Jennifer Jones',
    icon: booking,
    color: '#ff9999',
  },
  {
    start: '2026-12-04T12:00',
    end: '2026-12-07T12:00',
    title: 'Robert Garcia',
    icon: booking,
    color: '#ff9999',
  },
  {
    start: '2026-12-23T12:00',
    end: '2026-12-24T12:00',
    title: 'Linda Miller',
    icon: booking,
    color: '#ff9999',
  },
  {
    start: '2026-12-30T12:00',
    end: '2026-12-31T12:00',
    title: 'John Davis',
    icon: booking,
    color: '#ff9999',
  },
  {
    start: '2026-11-19T12:00',
    end: '2026-11-21T12:00',
    title: 'Elizabeth Rodriguez',
    icon: makeMyTrip,
    color: '#a0efaa',
  },
  {
    start: '2026-12-17T12:00',
    end: '2026-12-19T12:00',
    title: 'David Martinez',
    icon: makeMyTrip,
    color: '#a0efaa',
  },
  {
    start: '2026-12-20T12:00',
    end: '2026-12-22T12:00',
    title: 'Barbara Wilson',
    icon: makeMyTrip,
    color: '#a0efaa',
  },
  {
    start: '2026-11-25T12:00',
    end: '2026-11-26T12:00',
    title: 'William Anderson',
    icon: makeMyTrip,
    color: '#a0efaa',
  },
  {
    start: '2026-12-27T12:00',
    end: '2026-12-30T12:00',
    title: 'Susan Taylor',
    icon: makeMyTrip,
    color: '#a0efaa',
  },
  {
    start: '2026-12-10T12:00',
    end: '2026-12-13T12:00',
    title: 'Richard Jackson',
    icon: airBnB,
    color: '#fffa61',
  },
];

// A night is booked when a reservation spans the midnight following the given day
function getWeekSummary(args) {
  var events = args.events || [];
  var day = new Date(args.startDate);
  var nights = 0;
  var bookedNights = 0;
  var checkIns = 0;

  while (day <= args.endDate) {
    var midnight = new Date(day.getFullYear(), day.getMonth(), day.getDate() + 1);
    var isBooked = events.some(function (ev) {
      return new Date(ev.start) < midnight && new Date(ev.end) > midnight;
    });
    nights++;
    bookedNights += isBooked ? 1 : 0;
    day = midnight;
  }

  events.forEach(function (ev) {
    var start = new Date(ev.start);
    if (start >= args.startDate && start < day) {
      checkIns++;
    }
  });

  var occupancy = nights ? Math.round((bookedNights / nights) * 100) : 0;

  return {
    bookedNights: bookedNights,
    checkIns: checkIns,
    level: occupancy >= 70 ? 'high' : occupancy >= 40 ? 'medium' : 'low',
    nights: nights,
    occupancy: occupancy,
  };
}

mobiscroll.eventcalendar('#demo-booking-calendar', {
  view: {
    calendar: {
      type: 'month',
      eventDisplay: 'exact',
    },
  },
  data: myEvents,
  clickToCreate: true,
  dragToCreate: true,
  dragToMove: true,
  dragToResize: true,
  eventOverlap: false,
  extendDefaultEvent: function (args) {
    var start = new Date(args.start.setHours(12));
    var end = new Date(args.start.getFullYear(), args.start.getMonth(), args.start.getDate() + 1, 12);
    return {
      title: 'New reservation',
      start: start,
      end: end,
    };
  },
  renderCalendarEventContent: function (event) {
    return (
      '<div class="mbsc-flex mds-booking-item mbsc-align-items-center">' +
      (event.original.icon ? '<img class="mds-booking-icon" draggable="false" src=' + event.original.icon + '>' : '') +
      '<span>' +
      event.title +
      '</span></div>'
    );
  },
  renderCalendarSidebarEndHeader: function () {
    return '<div class="mds-booking-summary-header">Occupancy</div>';
  },
  renderCalendarSidebarEnd: function (args) {
    var summary = getWeekSummary(args);

    return (
      '<div class="mds-booking-summary">' +
      '<div class="mds-booking-summary-value">' +
      summary.occupancy +
      '%</div>' +
      '<div class="mds-booking-summary-bar">' +
      '<div class="mds-booking-summary-fill mds-booking-summary-' +
      summary.level +
      '" style="width:' +
      summary.occupancy +
      '%"></div></div>' +
      '<div class="mds-booking-summary-detail">' +
      summary.bookedNights +
      '/' +
      summary.nights +
      ' nights</div>' +
      '<div class="mds-booking-summary-detail">' +
      summary.checkIns +
      ' check-in' +
      (summary.checkIns === 1 ? '' : 's') +
      '</div></div>'
    );
  },
  onEventCreateFailed: handleOverlap,
  onEventUpdateFailed: handleOverlap,
});
  

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.