php - 如何找出特定位置的特定日期时间的时区?

标签 php timezone

我有另一个国家的事件日期,我需要将其保存在数据库中。问题是那些日期没有包含时区信息。

此位置使用的时区是 CET(标准时间)或 CEST(夏令时)。

检测哪一个正在播放的最简单方法是什么?

最佳答案

我不太确定你在问什么。我认为您需要了解的是特定日期是否在夏令时。如果是这样,您可以使用 date('I')

$dst_now = date('I'); // whether our current timezone is currently in DST
$dst_then = date('I', strtotime($date)); // whether that date is in DST for our current timezone

$date_obj = new DateTime($date, new DateTimeZone('Europe/Paris'));
$dst_thereandthen = $date_obj->format('I');
// whether that date is in DST for that timezone

如果您需要的不是这些,请说明您需要什么...

关于php - 如何找出特定位置的特定日期时间的时区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8609560/

相关文章:

timezone - 无法更改 GitLab 时区

python - 如何从任何地方查找特定时区的时间

java - 在java中将EST时间转换为本地时间

php - 如何解码 JSON 字符串

javascript - 将 JavaScript 日期从一个时区转换为另一时区?

ruby-on-rails - 为什么在始终设置 Time.zone 的情况下,在 Rails 中使用 Time.current 而不是 Time.zone.now?

php - 如何为 PHP 安装 ffmpeg

php - 我的 IF 语句正在更改 PHP 中的变量

php - 使用 Multi-cURL 的正确示例是什么?

php - 使用 Symfony2 和 Doctrine2 开发 Multi-Tenancy 应用程序的最佳实践