我有直接来自Google日历的事件的“列表”视图。 Google日历设置为“美国/中央”时区。我需要在“美国/东部”时区中显示事件。
我找到了示例,但似乎无法使它们正常工作。我正在提供我的基本代码,希望有人可以帮助我。
colorPrimary
当前,我的活动仅在UTC中显示。
答案 0 :(得分:0)
我明白了。
我必须同时添加timezone和timezoneParam来获取日历,以将时间调整为正确的时区。这是我删除了键后的最终代码。
<link href='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.css' rel='stylesheet' />
<link href='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/gcal.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.23/moment-timezone-with-data.min.js'></script>
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
defaultView: 'list',
defaultDate: '2019-04-01',
timezone: 'America/New_York',
timezoneParam : "America/New_York",
duration: {
days: 7
},
header: {
left: '',
center: '',
right: ''
},
displayEventTime: true, // don't show the time column in list view
height: 450,
// THIS KEY WON'T WORK IN PRODUCTION!!!
// To make your own Google API key, follow the directions here:
// http://fullcalendar.io/docs/google_calendar/
googleCalendarApiKey: 'YOUR_KEY',
// US Holidays
events: 'YOUR_CALENDAR@group.calendar.google.com',
eventClick: function(event) {
// opens events in a popup window
window.open(event.url, 'gcalevent', 'width=700,height=600');
return false;
},
loading: function(bool) {
$('#loading').toggle(bool);
}
});
});
</script>