Best way to get timezone of user based on area code
I'm attempting to get a timezone of a user based on area code information that they provided. I discovered the following resource on maxmind:
http://geolite.maxmind.com/download/geoip/api/php/timezone/
I suspect that I could use this with another api that provides the state that an area code belong开发者_开发知识库s to. I'm looking for a simple REST API that provides this info - or a robust scraping routine that achieve the same results.
Thanks in advance!
I'd caution against this approach. A lot of my friends (those in the 18 to 30 demographic) move across the country and keep their old cell phone numbers. The area code is less and less an indication of current location and more and more an indication of where someone lived at one time. With google voice accounts people might get an area code because they like the number and have never lived there!
I don't know of any specific API made for this, but if you want to store the area code database locally, NANPA is in charge of managing them.
Here's a good starting point http://www.nationalnanpa.com/area_codes/index.html
If you are OK with adding Javascript to your project, then you may want to try ChronoMouse.js, which will help get the current time, GMT offset, time zone name, location, capital city, daylight savings laws, or daylight savings status for any US/Canada area code, or country code.
For country codes, the info is based off of the capital city.
For example:
console.log( getLocalInfo('+49').time.display );
// 15:07
For more examples and documentation, see www.chronomouse.com.
Note: I am the author of the project.
精彩评论