获取 PHP 中的美国官方时区?

2024-08-14php开发问题
6

本文介绍了获取 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 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 中的美国官方时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17