Get Time Zone Offset in Seconds by Time Zone Name using PHP

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

Leave a Comment

Cancel reply

Your email address will not be published.