简体   繁体   English

在PHP中要偏移的TimeZone位置

[英]TimeZone location to offset in PHP

Google Calendar's XML feed includes a value to indicate the timezone of the calendar , but it only includes a long format time zone ID, rather than the time offset. Google日历的XML Feed中包含一个值,用于指示日历的时区 ,但它仅包含长格式的时区ID,而不是时间偏移。

eg 例如

<gCal:timezone value="Australia/Hobart"/>

or 要么

<gCal:timezone value='Europe/London'/>

Is there an easy way to translate these location values into aa timezone offset (like +11 hours ?) This value would need to reflect the current daylight saving status of the locale. 是否有一种简单的方法可以将这些位置值转换为时区偏移量(例如+11 hours ?),所以该值需要反映该语言环境的当前夏时制状态。

Alternatively, is there any way to get Google Calendar to include this timezone offset in the XML data? 另外,是否有任何方法可以让Google日历在XML数据中包含此时区偏移量?

This will give you the timezone offset in seconds, relative to UTC: 这将使您相对于UTC的时区偏移量(以秒为单位):

$timezone = 'Europe/London';
$dt = new DateTime('now', new DateTimeZone($timezone));
echo $dt->getOffset();

You can get a list of all supported timezones by calling 您可以通过致电获取所有支持的时区的列表

DateTimeZone::listIdentifiers() 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM