Guess timezone name for custom date

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

I know that I can get browser timezone name: moment.tz.guess()

How can I guess timezone for custom date? e.g. moment("2020-12-30T14:17:40+11:00").tz.guess() ?

回答1:

You can't. There are 9 different location-based zones that use +11:00 year round, and 5 more that use it for daylight saving time.

You might be able to eliminate a few if the date and time put it into a time zone where daylight time is not in effect and the standard time doesn't match, but from there, the best you could do would be to pick one at random.

See "time zone != offset" in the timezone tag wiki.

Moment-timezone can guess the browser's time zone because it can query the offset for multiple different timestamps, algorithmically reducing the possibilities. Even then, there are often several that could match, and thus the most likely one is picked (based on population statistics). In the end, it's still a guess.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!