Get the official American time zone in PHP?

后端 未结 2 1424
天命终不由人
天命终不由人 2020-12-07 06:38

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 th

2条回答
  •  被撕碎了的回忆
    2020-12-07 07:11

    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.

提交回复
热议问题