获取PHP的官方美国时区? [英] Get the official American time zone in PHP?
问题描述
我的帐户已存储在数据库中,并且每个帐户的状态都在文件中,我希望从那里将每个帐户链接到基于该帐户状态的时区.
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 由 大西洋 东 中央 山 太平洋地区 阿拉斯加州 夏威夷-阿留申语
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)如何确定哪个状态链接到哪个时区. (例如:加利福尼亚=美国/洛杉矶")
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的官方美国时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!