Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
649 views
in Technique[技术] by (71.8m points)

php - How to get timezone from airport code (IATA/FAA)

I am trying to make a PHP function that returns the UTC timezone for a given airport code (IATA/FAA).

What the function should do is something like this:

echo getTimezoneFromAirportCode("CPH"); // +1
echo getTimezoneFromAirportCode("CXI"); // +14

To make this function I need a list of all aiport codes and their timezones.

By searching a bit I found this list: https://sourceforge.net/p/openflights/code/HEAD/tree/openflights/data/airports.dat?format=raw (Source: http://openflights.org/data.html)

After looking up a couple of airport codes in the list I found out that some of the data was incorrect. For instance it lists CXI to be in the UTC -12 timezone - which according to this page is incorrect.

Does any of you know a public list that provides the data needed to make the getTimezoneFromAirportCode function?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Seeing as the question is still open I'd like to point to my very own timezone map files. For your particular purpose, the IATA tzmap seems perfect:

https://raw.github.com/hroptatyr/dateutils/tzmaps/iata.tzmap

Obviously, you'd have to snarf the offset in question (it depends on a date as it might change over time) from the zoneinfo files, e.g. with zdump(1).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...