tags:

views:

1109

answers:

7

I've gotten a request to show a person's local time based on their phone number. I know our local GMT offset, so I can handle USA phones via a database table we have that links US zip_code to GMT offset (e.g. -5). But I've no clue how to convert non-US phone numbers or country names (these people obviously don't have a zip code).

If you care, my employer college wants to solicit our alumni for donations and do it during reasonable hours.

Sorry to all that I didn't clearly state that I was considering HOME phone numbers. So roaming isn't an issue. I'm looking for some reference table or Oracle application I can source this info from.

Thanks,

Stew

A: 

You might be able to get the phone company to feed you location data (this info should exist for land lines and must exist for cells) but expect to pay.

BCS
A: 

Some nations are easy, since they are in a single time-zone. Look at Europe and add millions of people by just using the internation dialing code. +47 for Norway etc.

Phone-number allocations are usually done by a national telecom authority, so you could probably get the information for free.

As you allready know this would only take into account default-timezone, since they might be anywhere on the planet at the time. Also number-allocation might not distingish at all between timezones, so the approach is buggy but potentially usefull to provide default settings.

Regards

tovare
+5  A: 

Florida has two time zones, but many countries only have one. You need this table: http://en.wikipedia.org/wiki/List_of_country_calling_codes . Parse the country code out of the phone number by looking for the 1 and the area code for NANPA countries (those countries using the same 1+area code allocation as the USA), 7 for Russia or Kazakhstan. If that doesn't match check to see whether the number starts with one of the 2 digit calling prefixes, and then the 3-digit ones.

Remember that the first few digits of the number may be the international dialing prefix, and are not properly part of the telephone number.

For countries that span more than one time zone, see if you can get allocation information from their national telecom regulator. For the USA and other NANPA countries, check out http://www.nanpa.com/ .

Of course your results will be far from perfect, but hopefully you will wake fewer customers from their night's sleep.

joeforker
Thanks for these links. I actually work for a college and will be showing the local time value so that we solicit our alumni during reason times of day. We're *trying* to do the right thing!
Stew S
If you already have their phone numbers, surely you have their address?
joeforker
A: 

Look in the phone book. Ours has quite a few pages mapping area codes onto countries/provinces/states. Then you have to map geographical locations onto time zones, but that is pretty straightforward.

dar7yl
A: 

Impossible. If I drive about 400 miles east (west coast of the US) then I'll break your algorithm by having a XXX number in a YYY timezone.

Now if this is a cell phone app, it does seem possible with something called NITZ.

jcollum
J,Thanks but I'm not trying to deal with cell phones, just home.
Stew S
+1  A: 

Local time is one thing but, if you have worldwide customers, there are also local habits to take into account.

People typically go to bed earlier in Norway than in Spain (and they are in the same time zone).

bortzmeyer
A: 

I think Danie, Bortzmeyer, and others are over thinking the problem. It's not to maximize the calling window, it's to find an acceptable time.

Let's take the US and consider only the 4 major timezones. Say we define acceptable as from 10AM - 7PM. I doubt even the Norwegian Bachelor farmers go to be before 7PM.

So if you know that the phone is in the US, don't make any call before 1PM. That way if they are in NYC or LA, it's still after 10AM. And no calls after 7PM. Who cares if it's Florida main or its hour later panhandle? Dallas or El Paso, also same state but different time zones. For US, filter for AK and HI. The only seriously difficult country is Russia -- lots-o-timezones.