我有另一个国家的事件日期,我需要将其保存在数据库中。问题是那些日期没有包含时区信息。
此位置使用的时区是 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/