Facebook API,时区和国家 [英] Facebook API, timezone and country

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

问题描述

我正在开发一个网站,用户可以使用其Facebook凭据登录.

I am developing a website where the users can log in with their Facebook credentials.

现在,我面临日期和时间问题.我的本地系统使用的浪漫标准时间"与Facebook使用的不同.

Now I am facing an issue with Date and Times. My local system uses the "Romance Standard Time" which is different to what Facebook uses.

我在本地使用DST,根据一年中的时间,我们可以是UTC + 1或UTC + 2.

Where I am locally we use DST and depending on the time of the year we can either be at UTC + 1 or UTC + 2.

我的问题是,考虑到UTC + 1和UTC + 2之间的偶尔变化,我如何将Facebook时间转换为本地系统将使用的格式?"

My question is, "How can I translate the Facebook times into the format my local system will use, taking into account the occasional change between UTC+1 and UTC+2?"

推荐答案

此文档,用户更改时区的唯一方法是更改​​计算机的时区,然后注销并重新登录Facebook.这会让我相信,他们只是在浏览器中的JavaScript中获取UTC的偏移量,然后将其传递回服务器.

Per this documentation, the only way for a user to change their timezone is to change their computer's timezone and log out and back in to Facebook. This would lead me to believe that they are simply taking the offset from UTC in JavaScript in the browser and passing it back to the server.

因此,从Facebook Graph API返回的timezone字段的值可能是自用户上次登录以来的偏移量.

So the value of the timezone field coming back from the Facebook Graph API is probably the offset as of the last time the user logged in.

也有可能代表自用户注册之日起的偏移量,并且该偏移量不能更改.我在文档中找不到任何参考,因此必须进行实验才能确定.

It's also possible it represents the offset as of the date the user signed up, and that it can't change. I couldn't find any reference in the documentation, so one would have to experiment to be sure.

无论采用哪种速率,都无法仅从偏移量得出时区.有许多时区具有相同的偏移量.有关有用的类比,请在此处.

At either rate, one can't derive the time zone from the offset alone. There are many time zones that have the same offset. For a useful analogy, see my answer on a related subject here.

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

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