根据电话号码计算人的时区(GMT 偏移量)?

发布于 2024-07-11 20:50:11 字数 304 浏览 7 评论 0原文

我收到了根据某人的电话号码显示其当地时间的请求。 我知道我们当地的 GMT 偏移量,因此我可以通过我们拥有的数据库表来处理美国电话,该数据库表将美国邮政编码链接到 GMT 偏移量(例如 -5)。 但我不知道如何转换非美国电话号码或国家/地区名称(这些人显然没有邮政编码)。

如果您关心的话,我的雇主学院希望向我们的校友募集捐款,并在合理的时间内进行。

抱歉,我没有明确表明我正在考虑家庭电话号码。 所以漫游不是问题。 我正在寻找一些可以从中获取此信息的参考表或 Oracle 应用程序。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

七秒鱼° 2024-07-18 20:50:11

佛罗里达州有两个时区,但许多国家只有一个时区。 您需要此表: http://en.wikipedia.org/wiki/List_of_country_calling_codes 。 通过查找 NANPA 国家/地区的 1 和区号(这些国家/地区使用与美国相同的 1+区号分配)、7 来解析电话号码中的国家/地区代码,7 表示俄罗斯或哈萨克斯坦。 如果不匹配,请检查该号码是否以 2 位呼叫前缀之一开头,然后是 3 位呼叫前缀。

请记住,号码的前几位数字可能是国际拨号前缀,而不是电话号码的正确组成部分。

对于跨越多个时区的国家/地区,请查看是否可以从其国家电信监管机构获取分配信息。 对于美国和其他 NANPA 国家/地区,请查看 http://www.nanpa.com/

当然,您的结果远非完美,但希望您能将更少的顾客从睡梦中吵醒。

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.

一刻暧昧 2024-07-18 20:50:11

当地时间是一回事,但如果您有全球客户,还需要考虑当地的习惯。

人们通常比西班牙人更早睡觉(而且他们位于同一时区)。

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

鹿童谣 2024-07-18 20:50:11

您也许可以让电话公司向您提供位置数据(固定电话应该存在此信息,手机也必须存在此信息),但需要付费。

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.

迷爱 2024-07-18 20:50:11

有些国家很容易,因为它们位于同一个时区。 看看欧洲,只需使用国际电话代码就可以增加数百万人。 +47 代表挪威等。

电话号码分配通常由国家电信机构完成,因此您可能可以免费获得信息。

正如您所知,这只会考虑默认时区,因为它们当时可能位于地球上的任何地方。 此外,时区之间的数字分配可能根本没有区别,因此该方法存在缺陷,但对于提供默认设置可能很有用。

问候

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

琴流音 2024-07-18 20:50:11

查一下电话簿。 我们有相当多的页面将区号映射到国家/省/州。 然后您必须将地理位置映射到时区,但这非常简单。

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.

ら栖息 2024-07-18 20:50:11

不可能的。 如果我向东(美国西海岸)行驶约 400 英里,那么我将通过在 YYY 时区中使用 XXX 号码来破坏您的算法。

现在,如果这是一个手机应用程序,则似乎可以使用 名为 NITZ 的东西< /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.

星星的轨迹 2024-07-18 20:50:11

我认为丹妮、博茨迈尔和其他人对这个问题的思考过度了。 这不是为了最大化调用窗口,而是为了找到一个可接受的时间。

我们以美国为例,只考虑 4 个主要时区。 假设我们将可接受的时间定义为上午 10 点至晚上 7 点。 我怀疑即使是挪威的单身农民也不会在晚上 7 点之前上班。

因此,如果您知道手机在美国,请不要在下午 1 点之前拨打任何电话。 这样,如果他们在纽约或洛杉矶,时间仍然是上午 10 点之后。 晚上七点以后就没有电话了。 谁在乎这是佛罗里达主干道还是一小时后的狭长地带? 达拉斯或埃尔帕索,也是同一州但不同时区。 对于美国,过滤 AK 和 HI。 唯一严重困难的国家是俄罗斯——时区很多。

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.

随遇而安 2024-07-18 20:50:11

你可以找一个电话查询服务,比如Signalwire提供的服务,当然,如果这个人在东海岸度假,但电话号码来自加州,那么你就会得到“错误”

https://developer.signalwire.com/rest/phone-number-lookup/

You can se a Phone lookup service, for instance the one provided by Signalwire, of course if the person is in the East Coast just on vacation but the phone number is from California, then you will get it “wrong”

https://developer.signalwire.com/rest/phone-number-lookup/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文