开发者

How do I get the timezone from a string containing a datetime value in PHP?

Given the following string: 2011/09/18 11:59PM EDT, 2011-09-18T23:59:5开发者_如何学Go9+00:00

How do I extract the timezone part from this string using PHP?


Create a new DateTime object from the string, and use getTimezone on it to get the timezone:

$time = '2011/09/18 11:59PM EDT';
$dt = new DateTime($time);
print_r($dt->getTimezone()->getName());

See it in action.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜