Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
597 views
in Technique[技术] by (71.8m points)

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

so if the account's state is California then the timezone will be "America/Los_Angeles"

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

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.

So My question 1) How can I figure out what state is linked to what timezone. (example: California = "America/Los_Angeles")

2) Which timezone are linked to what timezone category. (example: California = Pacific)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You haven't thought this through.

Many US states have multiple time zones. For example, South Dakota has both Mountain and Central time zones.

South Dakota Time Zone Map

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...