tags:

views:

128

answers:

2

My calendar works properly on servers in PST but on the production server (EST) all events seem to end one day early. I am not sure if it is a timezone problem because even with the 3 hour difference the events should be display on the proper date.

Has anyone else encountered this issue?

+1  A: 

This is typical problem when crossing timezone barriers. If only the date is carried by the database, but the data is converted to timestamp and adjusted for timezone you have the problem 2010-06-02 becomes 2010-06-02 00:00 EST becomes 2010-06-01 21:00 PST.

BillThor
A: 

If the events end a day early but don't start a day early, it's likely your back-end scripts aren't getting or aren't respecting the end-date timezone information coming from the browser. If events start at midnight PDT (or 3am EDT) and but end at midnight EDT (or 9pm PDT) or maybe midnight GMT (or 4pm PDT), that would account for events "ending early". The browser should be sending all events with full datetime information (e.g. '6/3/2010 00:00:00 GMT-0800') and the back-end scripts be saving and reporting this information faithfully as well.

I live in Japan but do a lot of development in North America, so I see this problem constantly. I find it really helps development to think about all events in GMT rather than your own home timezone -- especially if any of your users live in different timezones. JS handles timezone information pretty well (aside from the lack of awareness of Daylight Saving Time, it works fantastically), and most servers do timezone extremely well, so most bugs you see have to do with client scripts sending incomplete date information and trying to make do.

It's also worth checking to see how your application works on November 7 2010 at 2:00am, since that day is 25 hours long and March 13, 2011, since that day's only 23 hours long. The switch to DST is a devil.

Andrew