[sourcecode language="php"]
function getOffsetByTimeZone($localTimeZone)
{
$time = new DateTime(date('Y-m-d H:i:s'), new DateTimeZone($localTimeZone));
$timezoneOffset = $time->format('P');
return $timezoneOffset;
}
[/sourcecode]
Call this function passing a local time zone as a string.
eg.
getOffsetByTimeZone('America/New_York');
No comments:
Post a Comment