开发者

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.

e.g.

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

or

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

Is there an easy way to translate these location values into a a开发者_如何学JAVA timezone offset (like +11 hours?) This value would need to reflect the current daylight saving status of the locale.

Alternatively, is there any way to get Google Calendar to include this timezone offset in the XML data?


This will give you the timezone offset in seconds, relative to 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() 


You can make use on DateTimeZone::listAbbreviations and DateTimeZone::listIdentifiers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜