I have a list of locations. Here are example locations:
Los Angeles, California
London, United Kingdom
New York, New York
Calgary, Alberta
Toronto, Ontario
Sydney, Australia
Phoenix, Arizona
Chicago, Illinois
Las Vegas, Nevada
Miami, Florida
Mexico City, Mexico
Houston, Texas
San Diego, California
Manchester, United Kingdom
San Antonio, Texas
Atlanta, Georgia
Dallas, Texas
Brisbane, Queensland, Australia
Montreal, Quebec
Orlando, Florida
Edmonton, Alberta
Manila, Philippines
Paris, France
Melbourne, Victoria, Australia
Nashville, Tennessee
Minneapolis, Minnesota
Perth, Western Australia
Brooklyn, New York
Columbus, Ohio
Seattle, Washington
What I need is the closest/best matching PHP timezone.
I'm currently using a set of regular expressions:
$location_pregs = array(
"'.*(California|Nevada)'si" => "America/Los_Angeles",
"'.*United Kingdom'si" => "Europe/London",
"'.*New York'si" => "America/New_York",
"'.*Alberta'si" => "America/Edmonton",
"'.*Ontario'si" => "America/Toronto",
"'Sydney, Australia'si" => "Australia/Sydney",
"'.*Arizona'si" => "America/Phoenix",
"'.*Illinois'si" => "America/Chicago",
"'.*Mexico'si" => "America/Mexico_City",
"'(El Paso, Texas|.*Colorado)'si" => "America/Denver"
);
function getTimezoneAt ($location) {
global $location_pregs;
foreach ($location_pregs as $pn => $pc) {
if (preg_match($pn, $location)) {
return $pc;
}
}
return false;
}
The code above presently covers 27.157% of the locations I need to look up (factoring for popularity). I'd like to get that to 80% with minimal effort. I'm running into trouble in some places:
Miami, Florida. As far as I can tell, the closest relevant timezone is 'America/New_York'. But how can I be sure?
Houston, Texas. As far as I can tell, this should be 'America/Denver'. But again, how can I tell quickly if this is right?
What I need it a map of the PHP timezones and the geographic areas they cover so I can map the remaining location values quickly. I generally know the timezone in an area, however I do not know which PHP timezone to pick.