DateTime::getOffset method
<?php
function getTimezoneOffset(string $timezone): int
{
$tz = new DateTimeZone($timezone);
$dt = new DateTime('now', $tz);
return $dt->getOffset();
}
echo getTimezoneOffset('America/New_York'); // -14400
<?php
function getTimezoneOffset(string $timezone): int
{
$tz = new DateTimeZone($timezone);
$dt = new DateTime('now', $tz);
return $dt->getOffset();
}
echo getTimezoneOffset('America/New_York'); // -14400
Leave a Comment
Cancel reply