PHP Timezone Name to Offset PHP Timezone Name to Offset php php

PHP Timezone Name to Offset


you can use the following

<?php$timezone = 'Pacific/Nauru';$time = new \DateTime('now', new DateTimeZone($timezone));$timezoneOffset = $time->format('P');?>


Another option would be to use the available DateTimeZone::getOffset() method, which returns the offset in seconds for the time zone at the specified date/time.

$timezone = new DateTimeZone("Europe/Andorra");$offset   = $timezone->getOffset(new DateTime);


I like using PHP Carbon:

$offset = Carbon::now('Europe/Andorra')->offsetHours;