How can I help you?
Timezone in Vue Schedule component
3 Feb 202624 minutes to read
The Scheduler makes use of the current system time zone by default. If it needs to follow some other user-specific time zone, then the timezone property needs to be used. Apart from the default action of applying specific timezone to the Scheduler, it is also possible to set different time zone values for each appointments through the properties startTimezone and endTimezone which can be defined as separate fields within the event fields collection.
Note: timezone property only applicable for the appointment processing and current time indication.
Understanding date manipulation in JavaScript
The new Date() in JavaScript returns the exact current date object with complete time and timezone information. For example, it may return value such as Wed Dec 12 2018 05:23:27 GMT+0530 (India Standard Time) which indicates that the current date is December 12, 2018 and the current time is 5.23 AM on browsers following the IST timezone.
Scheduler with no timezone
When no timezone is explicitly set, the Scheduler uses the client browser’s timezone. As a result:
- Events are displayed based on the viewer’s local timezone.
- The same event may appear at different times for users in different regions.
In the following example, an appointment is displayed from 9:00 AM to 10:00 AM regardless of the viewer’s timezone because the start and end times are provided using new Date() and interpreted locally.
<template>
<div id='app'>
<div id='container'>
<ejs-schedule :height='height' :selectedDate='selectedDate' :eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='TimelineWeek'></e-view>
<e-view option='Month'></e-view>
<e-view option='Agenda'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ScheduleComponent as EjsSchedule, ViewDirective as EView, ViewsDirective as EViews, Day, Week, TimelineViews, Month, Agenda } from '@syncfusion/ej2-vue-schedule';
const data = [{
Id: 1,
Subject: 'Paris',
StartTime: new Date(2018, 1, 15, 9, 0),
EndTime: new Date(2018, 1, 15, 10, 0)
}];
const height = '550px';
const selectedDate = new Date(2018, 1, 15);
const eventSettings = {
dataSource: data
}
provide('schedule', [Day, Week, TimelineViews, Month, Agenda]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style><template>
<div id='app'>
<div id='container'>
<ejs-schedule :height='height' :selectedDate='selectedDate' :eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='TimelineWeek'></e-view>
<e-view option='Month'></e-view>
<e-view option='Agenda'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</template>
<script>
import { ScheduleComponent, ViewDirective, ViewsDirective, Day, Week, TimelineViews, Month, Agenda } from '@syncfusion/ej2-vue-schedule';
let data = [{
Id: 1,
Subject: 'Paris',
StartTime: new Date(2018, 1, 15, 9, 0),
EndTime: new Date(2018, 1, 15, 10, 0)
}];
export default {
name: "App",
components: {
"ejs-schedule": ScheduleComponent,
"e-views": ViewsDirective,
"e-view": ViewDirective
},
data() {
return {
height: '550px',
selectedDate: new Date(2018, 1, 15),
eventSettings: {
dataSource: data
}
}
},
provide: {
schedule: [Day, Week, TimelineViews, Month, Agenda]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style>Scheduler set to a specific timezone
A fixed timezone can be applied to the Scheduler using the timezone property. When this property is set, all appointments are rendered based on the specified timezone, regardless of the user’s local system timezone.
In the following example, the Scheduler is configured to use Eastern Time (UTC −05:00):
<template>
<div>
<div id='app'>
<div id='container'>
<ejs-schedule height='550px' :selectedDate='selectedDate' :timezone='timezone'
:eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='Month'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import { scheduleData } from './datasource.js';
import { ScheduleComponent as EjsSchedule, ViewDirective as EView, ViewsDirective as EViews, Day, Week, Month } from '@syncfusion/ej2-vue-schedule';
const eventSettings = { dataSource: scheduleData };
const selectedDate = new Date(2018, 1, 17);
const timezone = 'America/New_York';
provide('schedule', [Day, Week, Month]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style><template>
<div>
<div id='app'>
<div id='container'>
<ejs-schedule height='550px' :selectedDate='selectedDate' :timezone='timezone'
:eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='Month'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</div>
</template>
<script>
import { scheduleData } from './datasource.js';
import { ScheduleComponent, ViewDirective, ViewsDirective, Day, Week, Month } from '@syncfusion/ej2-vue-schedule';
export default {
name: "App",
components: {
"ejs-schedule": ScheduleComponent,
"e-views": ViewsDirective,
"e-view": ViewDirective
},
data() {
return {
eventSettings: { dataSource: scheduleData },
selectedDate: new Date(2018, 1, 17),
timezone: 'America/New_York'
}
},
provide: {
schedule: [Day, Week, Month]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style>Display events on same time everywhere with no time difference
To display events at the same time across all timezones, set the Scheduler’s timezone property to UTC. This ensures that event times stored in the database are displayed consistently for every user, without conversion.
<template>
<div>
<div id='app'>
<div id='container'>
<ejs-schedule height='550px' :selectedDate='selectedDate' :timezone='timezone'
:eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='Month'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import { fifaEventsData } from './datasource.js';
import { extend } from '@syncfusion/ej2-base';
import { ScheduleComponent as EjsSchedule, ViewDirective as EView, ViewsDirective as EViews, Day, Week, Month } from '@syncfusion/ej2-vue-schedule';
import { Timezone } from '@syncfusion/ej2-schedule';
let timezoneInstance = new Timezone();
let data = extend([], fifaEventsData, null, true);
for (var i = 0; i < data.length; i++) {
data[i].StartTime = timezoneInstance.removeLocalOffset(data[i].StartTime);
data[i].EndTime = timezoneInstance.removeLocalOffset(data[i].EndTime);
}
const eventSettings = { dataSource: data };
const selectedDate = new Date(2018, 5, 17);
const timezone = 'UTC';
provide('schedule', [Day, Week, Month]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style><template>
<div>
<div id='app'>
<div id='container'>
<ejs-schedule height='550px' :selectedDate='selectedDate' :timezone='timezone'
:eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='Month'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</div>
</template>
<script>
import { fifaEventsData } from './datasource.js';
import { extend } from '@syncfusion/ej2-base';
import { ScheduleComponent, ViewsDirective, ViewDirective, Day, Week, Month } from '@syncfusion/ej2-vue-schedule';
import { Timezone } from '@syncfusion/ej2-schedule';
let timezone = new Timezone();
let data = extend([], fifaEventsData, null, true);
for (var i = 0; i < data.length; i++) {
data[i].StartTime = timezone.removeLocalOffset(data[i].StartTime);
data[i].EndTime = timezone.removeLocalOffset(data[i].EndTime);
}
export default {
name: "App",
components: {
"ejs-schedule": ScheduleComponent,
"e-views": ViewsDirective,
"e-view": ViewDirective
},
data() {
return {
eventSettings: { dataSource: data },
selectedDate: new Date(2018, 5, 17),
timezone: 'UTC'
}
},
provide: {
schedule: [Day, Week, Month]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style>Set specific timezone for events
It is possible to set different timezone for Scheduler events by setting startTimezone and endTimezone properties within the eventSettings option. It allows each appointment to maintain different timezone and displays on Scheduler with appropriate time differences.
<template>
<div id='app'>
<div id='container'>
<ejs-schedule :height='height' :selectedDate='selectedDate' :eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='TimelineWeek'></e-view>
<e-view option='Month'></e-view>
<e-view option='Agenda'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ScheduleComponent as EjsSchedule, ViewDirective as EView, ViewsDirective as EViews, Day, Week, TimelineViews, Month, Agenda } from '@syncfusion/ej2-vue-schedule';
let data = [{
Id: 1,
Subject: 'Paris',
StartTime: new Date(2018, 1, 15, 10, 0),
EndTime: new Date(2018, 1, 15, 12, 30),
StartTimezone: 'Europe/Moscow',
EndTimezone: 'Europe/Moscow'
}];
const height = '550px';
const selectedDate = new Date(2018, 1, 15);
const eventSettings = {
dataSource: data
};
provide('schedule', [Day, Week, TimelineViews, Month, Agenda]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style><template>
<div id='app'>
<div id='container'>
<ejs-schedule :height='height' :selectedDate='selectedDate' :eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='TimelineWeek'></e-view>
<e-view option='Month'></e-view>
<e-view option='Agenda'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</template>
<script>
import { ScheduleComponent, ViewDirective, ViewsDirective, Day, Week, TimelineViews, Month, Agenda } from '@syncfusion/ej2-vue-schedule';
let data = [{
Id: 1,
Subject: 'Paris',
StartTime: new Date(2018, 1, 15, 10, 0),
EndTime: new Date(2018, 1, 15, 12, 30),
StartTimezone: 'Europe/Moscow',
EndTimezone: 'Europe/Moscow'
}];
export default {
name: "App",
components: {
"ejs-schedule": ScheduleComponent,
"e-views": ViewsDirective,
"e-view": ViewDirective
},
data() {
return {
height: '550px',
selectedDate: new Date(2018, 1, 15),
eventSettings: {
dataSource: data
}
}
},
provide: {
schedule: [Day, Week, TimelineViews, Month, Agenda]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style>Add or remove timezone names to/from the timezone collection
Instead of displaying all the timezone names within the timezone collection (more than 200 are displayed on the editor window timezone fields by default), you can customize the timezone collection at application end as shown in the following example.
<template>
<div id='app'>
<div id='container'>
<ejs-schedule :height='height' :selectedDate='selectedDate' :eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='Month'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import { ScheduleComponent as EjsSchedule, ViewDirective as EView, ViewsDirective as EViews, Day, Week, Month, timezoneData } from '@syncfusion/ej2-vue-schedule';
import { scheduleData } from './datasource.js';
let data = [
{ Value: 'America/New_York', Text: '(UTC-05:00) Eastern Time' },
{ Value: 'UTC', Text: 'UTC' },
{ Value: 'Asia/Kolkata', Text: '(UTC+05:30) India Standard Time' }
];
timezoneData.splice(0, timezoneData.length, ...data);
const height = '550px';
const selectedDate = new Date(2018, 1, 1);
const eventSettings = {
dataSource: scheduleData
};
provide('schedule', [Day, Week, Month]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style><template>
<div id='app'>
<div id='container'>
<ejs-schedule :height='height' :selectedDate='selectedDate' :eventSettings='eventSettings'>
<e-views>
<e-view option='Day'></e-view>
<e-view option='Week'></e-view>
<e-view option='Month'></e-view>
</e-views>
</ejs-schedule>
</div>
</div>
</template>
<script>
import { ScheduleComponent, ViewDirective, ViewsDirective, Day, Week, Month, timezoneData } from '@syncfusion/ej2-vue-schedule';
import { scheduleData } from './datasource.js';
let data = [
{ Value: 'America/New_York', Text: '(UTC-05:00) Eastern Time' },
{ Value: 'UTC', Text: 'UTC' },
{ Value: 'Asia/Kolkata', Text: '(UTC+05:30) India Standard Time' }
];
timezoneData.splice(0, timezoneData.length, ...data);
export default {
name: "App",
components: {
"ejs-schedule": ScheduleComponent,
"e-views": ViewsDirective,
"e-view": ViewDirective
},
data() {
return {
height: '550px',
selectedDate: new Date(2018, 1, 1),
eventSettings: {
dataSource: scheduleData
}
}
},
provide: {
schedule: [Day, Week, Month]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-buttons/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-dropdowns/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-inputs/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-navigations/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-popups/styles/material3.css";
@import "../node_modules/@syncfusion/ej2-vue-schedule/styles/material3.css";
</style>Timezone methods
offset
Calculates the offset (in minutes) between a UTC date and a specific timezone.
| Parameters | Type | Description |
|---|---|---|
| Date | Date | UTC time as date object. |
| Timezone | String | Timezone. |
Returns number
// Assume your local timezone as IST/UTC+05:30
let timezone = new Timezone();
let date: Date = new Date(2018,11,5,15,25,11);
let timeZoneOffset = timezone.offset(date,"Europe/Paris");
console.log(timeZoneOffset); //-60
convert
This method is used to convert the passed date from one timezone to another timezone.
| Parameters | Type | Description |
|---|---|---|
| Date | Date | UTC time as date object. |
| fromOffset | number/string | Timezone from which date need to be converted. |
| toOffset | number/string | Timezone to which date need to be converted. |
Returns Date
// Assume your local timezone as IST/UTC+05:30
let timezone = new Timezone();
let date = new Date(2018,11,5,15,25,11);
let convertedDate = timezone.convert(date, "Europe/Paris", "Asia/Tokya");
let convertedDate1 = timezone.convert(date, 60, -360);
console.log(convertedDate); //2018-12-05T08:55:11.000Z
console.log(convertedDate1); //2018-12-05T16:55:11.000Z
add
This method is used to add the time difference between passed UTC date and timezone.
| Parameters | Type | Description |
|---|---|---|
| Date | Date | UTC time as date object. |
| Timezone | String | Timezone. |
Returns Date
// Assume your local timezone as IST/UTC+05:30
let timezone = new Timezone();
let date = new Date(2018,11,5,15,25,11);
let convertedDate = timezone.add(date, "Europe/Paris");
console.log(convertedDate); //2018-12-05T05:25:11.000Z
remove
This method is used to remove the time difference between passed UTC date and timezone.
| Parameters | Type | Description |
|---|---|---|
| Date | Date | UTC as date object. |
| Timezone | String | Timezone. |
Returns Date
// Assume your local timezone as IST/UTC+05:30
let timezone = new Timezone();
let date = new Date(2018,11,5,15,25,11);
let convertedDate = timezone.remove(date, "Europe/Paris");
console.log(convertedDate); //2018-12-05T14:25:11.000Z
removeLocalOffset
This method is used to remove the local offset time from the date passed.
| Parameters | Type | Description |
|---|---|---|
| Date | Date | UTC as date object. |
Returns Date
// Assume your local timezone as IST/UTC+05:30
let timezone = new Timezone();
let date = new Date(2018,11,5,15,25,11);
let convertedDate = timezone.removeLocalOffset(date);
console.log(convertedDate); //2018-12-05T15:25:11.000Z
For a complete overview of resource scheduling features, visit the Vue Scheduler feature tour page. Explore live examples at Vue Scheduler example to knows how to present and manipulate data.