Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
646 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...