问题描述
我的数据库中存储了帐户,并且每个帐户状态都存档,从那里我想根据帐户状态将每个帐户链接到一个时区.
I have account stored in my database and I have each account state on file, from there I want to link each account to a timezone based on the account state.
因此,如果帐户所在的州是加利福尼亚州,则时区将为America/Los_Angeles"
so if the account's state is California then the timezone will be "America/Los_Angeles"
更多,我想分解此页面提供的时区 http://php.net/manual/en/timezones.america.php by大西洋东中央山太平洋阿拉斯加州夏威夷 - 阿留申
More, I want to break down the time zone that is provided at this page http://php.net/manual/en/timezones.america.php by Atlantic Eastern Central Mountain Pacific Alaska Hawaii - Aleutian
现在我将能够根据 7 个时区对我的数据进行排序,并且我可以将我的所有帐户链接到一个时区,以便我可以确定它们的时区.
Now I will be able to sort my data based on 7 time zones and also I can have all my account linked to a timezone so I can determine their time zone.
所以我的问题1)我怎样才能弄清楚什么状态与什么时区相关联.(例如:加利福尼亚 = "America/Los_Angeles")
So My question 1) How can I figure out what state is linked to what timezone. (example: California = "America/Los_Angeles")
2) 哪个时区与哪个时区类别相关联.(例如:加利福尼亚 = 太平洋)
2) Which timezone are linked to what timezone category. (example: California = Pacific)
推荐答案
你还没想好.
美国的许多州都有多个时区.例如,南达科他州同时拥有山区和中部时区.
Many US states have multiple time zones. For example, South Dakota has both Mountain and Central time zones.
如果您希望将位置解析为时区,则需要更精细的位置.理想情况下,一个纬度和经度.如果您没有,您可以估算邮政编码的质心纬度/经度,然后将其用于将其解析为时区的许多各种服务或数据库中的任何一种.但是要非常小心,并不是所有的邮政编码都代表物理位置,而且邮政编码经常变化.
If you desire to resolve a location to a time zone, you will need a much more granular location. Ideally, a latitude and longitude. If you don't have one, you can approximate the centroid lat/lon of a zip code, and then use that against any of many various services or databases that will resolve that to a time zone. But be very careful, not all zip codes represent physical locations, and zip codes change frequently.
这篇关于获取 PHP 中的美国官方时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!