DevExtreme v24.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

JavaScript/jQuery Scheduler - Time Zone Support

The JavaScript Scheduler allows its users to view appointments in different time zones. Set the timeZone property to specify the current time zone. This property accepts values from the IANA time zone database.

In this demo, you can use the drop-down menu above the JavaScript Scheduler to choose between the London, Berlin, and Helsinki time zones. To populate the menu, the getTimeZones utility method is used. It returns a list of all IANA time zones that is then filtered.

Backend API
$(() => { const currentDate = new Date(2021, 3, 27); const getTimeZones = function (date) { const timeZones = DevExpress.utils.getTimeZones(date); return timeZones.filter((timeZone) => locations.indexOf(timeZone.id) !== -1); }; const timeZones = getTimeZones(currentDate); const scheduler = $('#scheduler').dxScheduler({ dataSource: data, views: ['workWeek'], timeZone: timeZones[0].id, currentView: 'workWeek', currentDate, startDayHour: 8, height: 600, editing: { allowTimeZoneEditing: true, }, onOptionChanged(e) { if (e.name === 'currentDate') { locationSwitcher.option('items', getTimeZones(e.value)); } }, onAppointmentFormOpening(e) { const { form } = e; const startDateTimezoneEditor = form.getEditor('startDateTimeZone'); const endDateTimezoneEditor = form.getEditor('endDateTimeZone'); const startDateDataSource = startDateTimezoneEditor.option('dataSource'); const endDateDataSource = endDateTimezoneEditor.option('dataSource'); startDateDataSource.filter(['id', 'contains', 'Europe']); endDateDataSource.filter(['id', 'contains', 'Europe']); startDateDataSource.load(); endDateDataSource.load(); }, }).dxScheduler('instance'); const locationSwitcher = $('#location-switcher').dxSelectBox({ items: timeZones, displayExpr: 'title', inputAttr: { 'aria-label': 'Time zone' }, valueExpr: 'id', width: 240, value: timeZones[0].id, onValueChanged(data) { scheduler.option('timeZone', data.value); }, }).dxSelectBox('instance'); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/24.1.7/css/dx.light.css" /> <script src="js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div class="option"> <span>Office Time Zone</span> <div id="location-switcher"></div> </div> <div id="scheduler"></div> </div> </body> </html>
.option { display: flex; } .option > span { display: flex; align-items: center; margin-right: 10px; } .dx-scheduler { margin-top: 20px; }
const data = [ { text: 'Stand-up meeting', startDate: '2021-04-26T15:30:00.000Z', endDate: '2021-04-26T15:45:00.000Z', recurrenceRule: 'FREQ=DAILY', }, { text: 'Book Flights to San Fran for Sales Trip', startDate: '2021-04-28T18:00:00.000Z', endDate: '2021-04-28T19:00:00.000Z', }, { text: 'New Brochures', startDate: '2021-04-30T18:30:00.000Z', endDate: '2021-04-30T18:45:00.000Z', }, { text: 'Website Re-Design Plan', startDate: '2021-04-27T12:30:00.000Z', endDate: '2021-04-27T13:30:00.000Z', }, { text: 'Book Flights to San Fran for Sales Trip', startDate: '2021-04-28T16:00:00.000Z', endDate: '2021-04-28T15:00:00.000Z', }, { text: 'Prepare 2021 Marketing Plan', startDate: '2021-04-26T07:00:00.000Z', endDate: '2021-04-26T09:30:00.000Z', }, { text: 'Launch New Website', startDate: '2021-04-28T08:00:00.000Z', endDate: '2021-04-28T10:00:00.000Z', }, { text: 'Submit New Website Design', startDate: '2021-04-29T09:30:00.000Z', endDate: '2021-04-29T11:00:00.000Z', }, { text: 'Upgrade Server Hardware', startDate: '2021-04-30T06:30:00.000Z', endDate: '2021-04-30T08:00:00.000Z', }, { text: 'Approve New Online Marketing Strategy', startDate: '2021-04-30T11:00:00.000Z', endDate: '2021-04-30T12:30:00.000Z', }, { text: 'Final Budget Review', startDate: '2021-04-27T09:00:00.000Z', endDate: '2021-04-27T10:35:00.000Z', }]; const locations = ['Europe/London', 'Europe/Berlin', 'Europe/Helsinki'];

Users can edit the time zones of individual appointments in the appointment details form. To enable this functionality, set the editing.allowTimeZoneEditing property to true. Information about individual time zones is saved in the startDateTimeZone and endDateTimeZone fields of the appointment data objects.