Skip to content

Time Configuration

Configure time grid intervals, working hours, and time restrictions.

Set time slot intervals in minutes using grid:

<html>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@calendarjs/ce/dist/style.min.css" />
<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@calendarjs/ce/dist/index.min.js"></script>

<div id='schedule' style="height: 600px;"></div>

<script>
const { Schedule } = calendarjs;

Schedule(document.getElementById('schedule'), {
    type: 'week',
    grid: 30, // 30-minute intervals
    data: []
});
</script>
</html>
IntervalMinutesUse Case
15 min15Default, detailed scheduling
30 min30Standard appointments
60 min60Hourly blocks

grid controls how the time column is divided visually. snap is a separate setting that controls the create/resize gesture — every new or resized event will have a duration that is a multiple of snap minutes.

This is useful when you want a fine visual grid but only allow events of a fixed length, such as 60-minute lessons or 30-minute appointment slots:

<html>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@calendarjs/ce/dist/style.min.css" />
<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@calendarjs/ce/dist/index.min.js"></script>

<div id='schedule' style="height: 600px;"></div>

<script>
const { Schedule } = calendarjs;

Schedule(document.getElementById('schedule'), {
    type: 'week',
    grid: 15,   // 15-minute visual rows
    snap: 60,   // events snap to 60-minute increments
    data: []
});
</script>
</html>

snap defaults to whatever you pass for grid, so leaving it unset preserves the original behaviour. Passing a value smaller than grid also falls back to grid-sized snapping. For predictable results pass a clean multiple of grid (e.g. with grid: 15, use snap: 30, 45, 60...).

Restrict available hours using validRange:

<html>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@calendarjs/ce/dist/style.min.css" />
<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@calendarjs/ce/dist/index.min.js"></script>

<div id='schedule' style="height: 600px;"></div>

<script>
const { Schedule } = calendarjs;

Schedule(document.getElementById('schedule'), {
    type: 'week',
    validRange: ['09:00', '18:00'], // 9 AM to 6 PM only
    data: []
});
</script>
</html>

Block specific time periods using readOnlyRange:

import { Schedule } from '@calendarjs/ce';
import '@calendarjs/ce/dist/style.css';

// Lunch break: 12 PM - 1 PM
Schedule(document.getElementById('schedule'), {
    readOnlyRange: ['12:00', '13:00'],
    data: []
});
import { Schedule } from '@calendarjs/ce';
import '@calendarjs/ce/dist/style.css';

// Block before 9 AM and after 6 PM, plus lunch
Schedule(document.getElementById('schedule'), {
    readOnlyRange: [
        ['00:00', '09:00'], // Before work
        ['12:00', '13:00'], // Lunch
        ['18:00', '23:59']  // After work
    ],
    data: []
});
<html>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@calendarjs/ce/dist/style.min.css" />
<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@calendarjs/ce/dist/index.min.js"></script>

<div id='schedule' style="height: 600px;"></div>

<script>
const { Schedule } = calendarjs;

Schedule(document.getElementById('schedule'), {
    type: 'week',
    grid: 30,                        // 30-minute slots
    validRange: ['08:00', '20:00'],  // 8 AM to 8 PM
    readOnlyRange: [
        ['12:00', '13:00'],          // Lunch break
        ['17:00', '17:30']           // Afternoon break
    ],
    data: []
});
</script>
</html>

Change time configuration at runtime:

import { Schedule } from '@calendarjs/ce';
import '@calendarjs/ce/dist/style.css';

const schedule = Schedule(document.getElementById('schedule'), {
    type: 'week',
    grid: 30,
    data: []
});

// Change grid interval
schedule.grid = 60;
schedule.render();

// Update valid range
schedule.setRange(['10:00', '16:00']);

// Update readonly range
schedule.setReadOnly([['12:00', '13:00']]);