如何找出特定地点特定日期时间的时区


How to find out timezone of specific datetime in specific location?

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

此位置使用的时区为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

如果你需要的不是这些,请说明你需要什么…

我假设date_default_timezone_get()函数会给您想要的信息,尽管我不完全确定它是否可以区分标准时间和夏令时。

函数()