_docs-v1/event-data/google-calendar.md
FullCalendar can display events from a public Google Calendar.<!--more--> Google Calendar can serve as a backend that manages and persistently stores event data (a feature that FullCalendar currently lacks).
<div class='warning'> On Nov 17th 2014, Google shut down V1 and V2 of their Calendar APIs, which FullCalendar relied upon. Please upgrade to the latest version of FullCalendar or at least replace <code>gcal.js</code> with <strong><a href='https://github.com/arshaw/fullcalendar/blob/v1.x/gcal.js'>this file</a></strong> (will work from FullCalendar v1.5.0 until the latest v1.x). Your own Google Calendar API key is now required. <strong>Also, the way you specify your event feed is different!</strong> Read below about <code>googleCalendarApiKey</code> and <code>googleCalendarId</code>. </div>You must first have a Google Calendar API Key:
Make your Google Calendar public:
Obtain your Google Calendar's ID:
Next, you must have all the required js/css files. This includes the standard fullcalendar.js and fullcalendar.css, in addition to gcal.js:
<script type='text/javascript' src='fullcalendar/gcal.js'></script>
Now it's time to initialize your calendar in JavaScript. You pass an object into the events parameter, with two required properties, googleCalendarApiKey and googleCalendarId:
<script type='text/javascript'>
$(function() {
$('#calendar').fullCalendar({
events: {
googleCalendarApiKey: '<YOUR API KEY>',
googleCalendarId: '[email protected]',
}
});
});
</script>
You can also specify some Event Source options:
<script type='text/javascript'>
$(function() {
$('#calendar').fullCalendar({
events: {
googleCalendarApiKey: '<YOUR API KEY>',
googleCalendarId: '[email protected]',
className: 'gcal-event', // an option!
currentTimezone: 'America/Chicago' // an option!
}
});
});
</script>
Sometimes it can be confusing as to why FullCalendar displays event times differently than the Google Calendar interface. There are the two factors involved in this:
When both timezones are the same, you should have no problems. When they are different, FullCalendar will display times in the calendar's timezone. Thus, times will be different than what you see in the Google Calendar interface because they are being adjusted to the GMT of the calendar. The solution is to use the currentTimezone option. If this is set to the same timezone as your Google Account, all dates should appear consistent.
You can specify multiple Google Calendars by using the eventSources option:
<script type='text/javascript'>
$(function() {
$('#calendar').fullCalendar({
eventSources: [
{
googleCalendarApiKey: "<YOUR API KEY>",
googleCalendarId: "[email protected]"
},
{
googleCalendarApiKey: "<YOUR API KEY>",
googleCalendarId: "[email protected]"
}
]
});
});
</script>