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.
精彩评论