Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set javascript Fullcalendar plugin base on timezone (GMT + 8)

I am using Fullcalendar plugin:

http://fullcalendar.io/

The problem is ,I found the calendar is quite confusing, as when I click on 00:00 am , it is 8:00 a.m if I logging the date

How to restrict the display date is same as the timezone, so that if I click on 00:00 , it is actually 00:00 GMT+8 , instead of 08:00 GMT + 8 ?

Thanks for helping.

like image 686
user3538235 Avatar asked Dec 21 '15 01:12

user3538235


2 Answers

You can use like:

<?php
    $datetime = new DateTime('now', 'America/Chicago');
    $datetime_string = $datetime->format('c');
?>

$('#calendar').fullCalendar({
    now: <?php echo json_encode($datetime_string) ?>
});
like image 191
Ishan Shah Avatar answered Oct 15 '22 19:10

Ishan Shah


You have to set timezone property of this plugin. Like this -

var currentTimezone = "Asia/Bangkok";
$('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                timezone: currentTimezone, << SET TIMEZONE HERE
                editable: true,
                selectable: true,
                eventLimit: true, // allow "more" link when too many events
            });

After setting timezone property your calendar will work base on that timezone.

Check official demo here - DEMO

like image 30
Napster Avatar answered Oct 15 '22 19:10

Napster