Documentation v8.1.1

Preview Downloads Purchase
Fullcalendar is the most popular Javascript Calendar. It's powerful and lightweight and suitable for just about anything. For more info see the official siteand the Github repository.

Local JS Timezone Example

Fullcalendar's example with timezones with local JS logic. For more info on server side logic, please visit the official documentation.
var initialTimeZone = "local";
var timeZoneSelectorEl = document.getElementById("kt_docs_fullcalendar_timezone_selector");
var calendarEl = document.getElementById("kt_docs_fullcalendar_timezone");
var todayDate = moment().startOf("day");
var YM = todayDate.format("YYYY-MM");
var YESTERDAY = todayDate.clone().subtract(1, "day").format("YYYY-MM-DD");
var TODAY = todayDate.format("YYYY-MM-DD");
var TOMORROW = todayDate.clone().add(1, "day").format("YYYY-MM-DD");
var eventsArray = [
    ...
];

// Initialize the external events -- for more info please visit the official site: https://fullcalendar.io/demos
var calendar = new FullCalendar.Calendar(calendarEl, {
    timeZone: initialTimeZone,
    headerToolbar: {
        left: "prev,next today",
        center: "title",
        right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek"
    },
    initialDate: TODAY,
    navLinks: true, // can click day/week names to navigate views
    editable: true,
    selectable: true,
    dayMaxEvents: true, // allow "more" link when too many events

    eventTimeFormat: { hour: "numeric", minute: "2-digit", timeZoneName: "short" },
    events: eventsArray,
});

calendar.render();

// when the timezone selector changes, dynamically change the calendar option
// --- more info on Select2 on Change event: https://select2.org/programmatic-control/events
$(timeZoneSelectorEl).on("change", function () {
    calendar.setOption("timeZone", "UTC");

    // Remove all events
    const removeEvents = calendar.getEvents();
    removeEvents.forEach(event => {
        event.remove();
    });

    // Add events with new timezone offset
    const newEvents = eventsArray;
    newEvents.forEach(event => {
        var start;
        var end;

        if(this.value < 0){
            start = moment(event.start).subtract(this.value.replace(/\D/g,""), "seconds").format(getFormat(event.start));
            end = event.end ? moment(event.end).subtract(this.value.replace(/\D/g,""), "seconds").format(getFormat(event.end)) : start;
        } else {
            start = moment(event.start).add(this.value, "seconds").format(getFormat(event.start));
            end = event.end ? moment(event.end).add(this.value, "seconds").format(getFormat(event.end)) : start;
        }

        calendar.addEvent({
            title: event.title,
            start: start,
            end: end
        });
    });

    calendar.render();
});

// Dynamic date format generator
const getFormat = (d) => {
    if(d.includes("T")){
        return "YYYY-MM-DDTHH:mm:ss";
    } else {
        return "YYYY-MM-DD";
    }
}
<!--begin::Localization dropdown-->
<div class="mb-5">
    <label class="fs-4 fw-bold mb-3">Select a Timezone:</label>
    <select id="kt_docs_fullcalendar_timezone_selector" class="form-select mw-200px" data-control="select2" data-placeholder="Select an option">
        ...
    </select>
</div>
<!--end::Localization dropdown-->

<!--begin::Fullcalendar-->
<div id="kt_docs_fullcalendar_timezone"></div>
<!--end::Fullcalendar-->

Demos

Metronic Licenses

License FAQs
Regular License
For single end product used by you or one client
$ 39
Extended License
For single SaaS app with paying users
$ 969
Custom License
Reach us for custom license offers.
Buy Now
Learn & Get Inspired

Support at devs.keenthemes.com

Join our developers community to find answer to your question and help others. FAQs
Get Support
Documentation & Videos
From guides and video tutorials, to live demos and code examples to get started.
Plugins & Components
Check out our 300+ in-house components and customized 3rd-party plugins.
Layout Builder
Build your layout, preview it and export the HTML for server side integration.
Metronic Downloads
Download your prefered framework and demo with one click.
What's New
Latest features and improvements added with our users feedback in mind.