jQuery FullCalendar时区同步 [英] jQuery FullCalendar timezone synchronization

查看:148
本文介绍了jQuery FullCalendar时区同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery Fullcalendar插件(http://arshaw.com/fullcalendar)。我只是将它用于全天活动。当用户创建一个事件时,我通过PHP将它作为日期(2012-01-12)存储在我的数据库中。当通过AJAX将事件列表发送到FullCalendar时,我将日期转换为Unix时间。

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.

我所预见的问题是,如果服务器处于美国有美国时区,客户在欧洲。服务器发送2012-01-12 00:00:00(美国时间)的事件,该事件被转换为Unix时间。然后,客户可能会看到2012-01-12 08:00:00(8小时后)发生的事件。

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).

如何确保如果发生事件是在午夜,然后是在午夜 - 无需调整任何时区。如果用户在1月12日创建了一整天的活动,我需要世界各地的每个用户在同一天也看到它。

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.

推荐答案

FullCalendar有一个选项,ignoreTimezone(参见: http://arshaw.com/fullcalendar/docs/event_data/ignoreTimezone/ ),只要确保它设置为true(默认情况下它是这样的*),并且用户将看到与服务器发送的时间相同的时间,而不管用户的时区。

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.)

这篇关于jQuery FullCalendar时区同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆