Show the week in:

OfficeLocal timeOffsetFor them

jQuery Scheduler: Meeting Planner (Time Zones)

A team in New York, London, Sofia and Tokyo plans its week. jqxScheduler shows the week in any office's time zone - its timeZone can be changed at any time - and follows daylight saving time: in this week Europe has already gone back to winter time and the United States has not. The hours the offices share are worked out with $.jqx.date.timeZoneOffset and everything else is a blocked time.

A live JavaScript/jQuery example of jqxScheduler, the jQWidgets Scheduler component, with its complete source code below. It is one of 45 jqxScheduler demos for jQuery.

jqxScheduler API used in this demo

Source code

To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $. Getting started with jqxScheduler shows the setup step by step.

The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxbuttons.js, jqxscrollbar.js, jqxdata.js, jqxdate.js, jqxscheduler.js, jqxscheduler.api.js, jqxdatetimeinput.js, jqxmenu.js, jqxcalendar.js, jqxtooltip.js, jqxwindow.js, jqxcheckbox.js, jqxlistbox.js, jqxdropdownlist.js, jqxnumberinput.js, jqxradiobutton.js, jqxinput.js.

It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).

script.js

$(document).ready(function () {
    // The week of 26 October 2026. Europe went back to winter time on 25 October, the United
    // States does on 1 November - so this week New York is four hours behind London, not five.
    // The meetings are stored in UTC; the scheduler shows them in the time zone it is given.
    var offices = [
        { city: 'New York', zone: 'Eastern Standard Time' },
        { city: 'London', zone: 'GMT Standard Time' },
        { city: 'Sofia', zone: 'FLE Standard Time' },
        { city: 'Tokyo', zone: 'Tokyo Standard Time' }
    ];
    // the offices that share office hours; Tokyo joins by recording
    var sharing = offices.slice(0, 3);
    var officeHours = { from: 9, to: 17 };

    var utc = function (day, hour, minute) { return new Date(Date.UTC(2026, 9, day, hour, minute || 0)); };
    var meetings = [
        { id: 'standup', subject: 'Team stand-up', location: 'Video call', start: utc(26, 14, 0), end: utc(26, 14, 30), rule: 'FREQ=DAILY;COUNT=5' },
        { id: 'design', subject: 'Design pairing (London, Sofia)', location: 'Video call', start: utc(27, 9, 0), end: utc(27, 10, 30) },
        { id: 'customer', subject: 'Customer call (New York)', location: 'Phone', start: utc(28, 18, 0), end: utc(28, 19, 0) },
        { id: 'review', subject: 'Sprint review', location: 'London office', start: utc(29, 14, 0), end: utc(29, 15, 0) },
        { id: 'handover', subject: 'Hand-over to Tokyo', location: 'Video call', start: utc(26, 23, 30), end: utc(27, 0, 0) }
    ];
    var source = {
        dataType: 'array',
        dataFields: [
            { name: 'id', type: 'string' },
            { name: 'subject', type: 'string' },
            { name: 'location', type: 'string' },
            { name: 'rule', type: 'string' },
            { name: 'start', type: 'date' },
            { name: 'end', type: 'date' }
        ],
        id: 'id',
        localData: meetings
    };

    // ---- time zone arithmetic: $.jqx.date.timeZoneOffset follows daylight saving ----
    var offset = function (zone, instant) { return $.jqx.date.timeZoneOffset(zone, instant); };
    // a moment as the clock in a zone shows it (read with the getUTC... methods)
    var clock = function (zone, instant) { return new Date(instant.getTime() + offset(zone, instant) * 60000); };
    var pad = function (n) { return (n < 10 ? '0' : '') + n; };
    var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
    var show = function (zone, instant) {
        var c = clock(zone, instant);
        return days[c.getUTCDay()] + ' ' + pad(c.getUTCHours()) + ':' + pad(c.getUTCMinutes());
    };

    // the hours of a day that every sharing office is open: the latest opening, the earliest closing
    var sharedHours = function (day) {
        var open = -Infinity, close = Infinity;
        $.each(sharing, function () {
            var noon = new Date(Date.UTC(2026, 9, day, 12));
            var minutes = offset(this.zone, noon);
            open = Math.max(open, Date.UTC(2026, 9, day, officeHours.from) - minutes * 60000);
            close = Math.min(close, Date.UTC(2026, 9, day, officeHours.to) - minutes * 60000);
        });
        return { open: new Date(open), close: new Date(close) };
    };

    // everything outside the shared hours is a blocked time - at clock times of the zone shown
    var blockedTimesIn = function (zone) {
        var blocked = [];
        var wall = function (instant) { var c = clock(zone, instant); return new Date(c.getUTCFullYear(), c.getUTCMonth(), c.getUTCDate(), c.getUTCHours(), c.getUTCMinutes()); };
        for (var day = 26; day <= 30; day++) {
            var shared = sharedHours(day);
            var open = wall(shared.open), close = wall(shared.close);
            var dayStart = new Date(open.getFullYear(), open.getMonth(), open.getDate());
            var dayEnd = new Date(open.getFullYear(), open.getMonth(), open.getDate() + 1);
            blocked.push({ from: dayStart, to: open, text: 'Outside shared hours' });
            blocked.push({ from: close, to: dayEnd, text: 'Outside shared hours' });
        }
        return blocked;
    };

    var current = offices[1];
    // the time ruler of the zone shown, named after its city, and a second one in UTC
    var viewsIn = function (office) {
        return [{ type: 'weekView', showWeekends: false, timeRuler: { formatString: 'HH:mm', text: office.city, timeZones: [{ id: 'UTC', text: 'UTC' }] } }];
    };
    $('#scheduler').jqxScheduler({
        date: new $.jqx.date(2026, 10, 28),
        width: '100%',
        height: 560,
        source: new $.jqx.dataAdapter(source),
        view: 'weekView',
        timeZone: current.zone,
        rowsHeight: 22,
        // meetings have times: no all-day row
        showAllDayRow: false,
        appointmentDataFields: { from: 'start', to: 'end', id: 'id', subject: 'subject', location: 'location', recurrencePattern: 'rule' },
        views: viewsIn(current),
        blockedTimes: blockedTimesIn(current.zone),
        ready: function () {
            // a little before the shared hours, at this zone's clock
            $('#scheduler').jqxScheduler('scrollToTime', clock(current.zone, sharedHours(28).open).getUTCHours() - 2);
        }
    });

    // ---- the week in another office's time zone ----
    $.each(offices, function (i, office) {
        $('<input type="button" />').val(office.city).attr('aria-pressed', office === current).appendTo('#zones').jqxButton({ height: 30 })
            .on('click', function () {
                current = office;
                $('#zones input').attr('aria-pressed', false);
                $(this).attr('aria-pressed', true);
                // the appointments keep their moments; the blocked times are clock times, so they are worked out again
                $('#scheduler').jqxScheduler({ timeZone: office.zone, blockedTimes: blockedTimesIn(office.zone), views: viewsIn(office) });
                $('#scheduler').jqxScheduler('scrollToTime', clock(office.zone, sharedHours(28).open).getUTCHours() - 2);
                describeWeek();
                describeMeeting();
            });
    });

    var describeWeek = function () {
        var mid = new Date(Date.UTC(2026, 9, 28, 12));
        var gap = (offset('GMT Standard Time', mid) - offset('Eastern Standard Time', mid)) / 60;
        var shared = sharedHours(28);
        $('#week').text('Shown in ' + current.city + ' time. This week New York is ' + gap + ' hours behind London (from 1 November, 5). ' +
            'New York, London and Sofia are all in the office from ' + show(current.zone, shared.open).slice(4) + ' to ' + show(current.zone, shared.close).slice(4) +
            ' ' + current.city + ' time - new meetings go there; Tokyo joins by recording.');
    };

    // ---- the meeting in every office ----
    var selected = null;
    var describeMeeting = function () {
        if (!selected) return;
        // the moment: a date in the scheduler's zone, read as such
        var start = selected.from.timeZone ? selected.from.toDate('Local') : selected.from.toDate();
        $('#meetingTitle').text(selected.subject);
        $('#cities tbody').empty().append($.map(offices, function (office) {
            var c = clock(office.zone, start);
            var hour = c.getUTCHours() + c.getUTCMinutes() / 60;
            var inHours = c.getUTCDay() > 0 && c.getUTCDay() < 6 && hour >= officeHours.from && hour < officeHours.to;
            return $('<tr></tr>')
                .append($('<td></td>').text(office.city))
                .append($('<td class="time"></td>').text(show(office.zone, start)))
                .append($('<td></td>').text('UTC' + (offset(office.zone, start) >= 0 ? '+' : '') + (offset(office.zone, start) / 60)))
                .append($('<td></td>').addClass(inHours ? 'in' : 'out').text(inHours ? 'in office hours' : 'outside office hours'));
        }));
    };
    $('#scheduler').on('appointmentClick', function (event) {
        // a meeting of a series: the occurrence that was clicked
        selected = event.args.occurrence || event.args.appointment;
        describeMeeting();
    });
    $('#scheduler').on('appointmentChange', function (event) {
        selected = event.args.appointment;
        describeMeeting();
    });

    describeWeek();
    selected = $.grep($('#scheduler').jqxScheduler('getAppointments'), function (a) { return a.id === 'review'; })[0];
    describeMeeting();
});

body.html

<div id="content" class="demo">
    
    <div class="demo-zones" id="zones"><span class="label">Show the week in:</span></div>
    <p class="demo-note" id="week" aria-live="polite"></p>
    <div id="scheduler"></div>
    <div class="demo-meeting">
        <h3 id="meetingTitle"></h3>
        <table id="cities" class="demo-cities" aria-live="polite">
            <thead><tr><th>Office</th><th>Local time</th><th>Offset</th><th>For them</th></tr></thead>
            <tbody></tbody>
        </table>
    </div>
</div>

Learn more

More jQuery Scheduler demos