Nathan H
Nathan H

Reputation: 49371

jQuery FullCalendar timezone synchronization

I am using the jQuery Fullcalendar plugin (http://arshaw.com/fullcalendar). I am only using it for "full day" events. When the user creates an event, I store it in my database via PHP as a date (2012-01-12). When sending the list of events to FullCalendar via AJAX, I convert the date to Unix time.

The problem I am foreseeing, is the case where say the server is in the US with a US timezone, and the client is in Europe. The server sends an event for 2012-01-12 00:00:00 (US Time), which gets converted to a Unix time. Then the client may see an event that is at 2012-01-12 08:00:00 (8 hours later).

How can I make sure that if an event is at midnight, then it's at midnight EVERYWHERE - no need adjust any timezone. If a user creates a full day event on January 12th, I need every user around the world to see it on that same date as well.

Upvotes: 2

Views: 4246

Answers (1)

David Webster
David Webster

Reputation: 324

FullCalendar has a option for this, ignoreTimezone (see: http://arshaw.com/fullcalendar/docs/event_data/ignoreTimezone/ ), just make sure this is set to true (which it is by default*) and the user will see the same time that the server sends, regardless of user's timezone.

(*personally I think the default is wrong, and the developer seems to acknowledge that in the docs, so it'd be worth setting explicitly.)

Upvotes: 5

Related Questions