2015-12-21 40 views
5

我使用Fullcalendar插件:坐落在時區的javascript Fullcalendar插件基地(GMT + 8)

http://fullcalendar.io/

的問題是,我發現日曆是相當混亂,因爲當我點擊00:00上午8:00如果我記錄日期

如何限制顯示日期與時區相同,所以如果我點擊00:00,它實際上是00:00 GMT + 8,而不是08:00 GMT + 8?

感謝您的幫助。

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

$('#calendar').fullCalendar({ 
    now: <?php echo json_encode($datetime_string) ?> 
}); 
+1

你試過改變時區嗎? http://fullcalendar.io/docs/timezone/timezone/ –

+1

分享您當前的代碼片段 –

+1

設置參數「時區:假」在日曆腳本應該做的。 – DpEN

回答

7

一樣可以使用。像這樣 -

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 
      }); 

設置timezone屬性後,您的日曆將基於該時區工作。

查看官方演示在這裏 - DEMO

+0

感謝您的回答 – user3538235

4

必須設置這個插件的時區屬性: