問題描述
如何將時區從 int
轉換為 string
(例如:Europe/Stockholm)
?
How do you convert a timezone from int
to string
(etc: Europe/Stockholm)
?
我正在使用 Facebooks PHP api 并且返回 ["timezone"] =>int(2)
.我該如何解析?
I'm using Facebooks PHP api and that returns ["timezone"] => int(2)
. How am I suppose to parse that?
推薦答案
如何將時區從整數轉換為字符串(例如:歐洲/斯德哥爾摩)?
How do you convert a timezone from int to string (etc: Europe/Stockholm)?
你不能.閱讀時區標簽維基中的Time Zone != Offset".
You can't. Read "Time Zone != Offset" in the timezone tag wiki.
Facebook 的文檔 解釋了時區
字段是用戶相對于 UTC 的時區偏移量.
Facebook's documentation explains that the timezone
field is the user's timezone offset from UTC.
它沒有說清楚,但我通過實驗發現,它不一定是用戶的當前偏移量,而是用戶上次登錄時的偏移量. 如果用戶更改時區,或者夏令時開始或結束,則在用戶下次登錄之前不會反映在 Facebook 數據中.
What it doesn't make clear, but I have found through experimentation, is that it is not necessarily the user's current offset, but it instead it is the offset as of the user's last log in. If the user changes time zones, or daylight saving time begins or ends, that will not be reflected in the Facebook data until the user's next log in.
另見這些帖子:
- Facebook API、時區和國家
- FaceBook 時區和活動時間
這篇關于將時區 int 解析為字符串(時區名稱)(facebook api)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!