In PHP, timezone_offset_get() returns the offset from UTC, in seconds, for a time zone at a specific date and time.
The offset depends on the date because of daylight saving time. New York is five hours behind UTC in winter and four hours behind in summer, so you must say which moment you mean. It is the procedural version of DateTimeZone::getOffset().
Syntax
Call timezone_offset_get() with the values you need. Start with this line.
PHP
$seconds = timezone_offset_get($tz, $date);
Call
What it does
timezone_offset_get($tz, new DateTime('2026-01-01'))
Returns the offset of the zone on January 1, 2026.
timezone_offset_get($tz, new DateTime('now'))
Returns the offset at the current moment.
$tz->getOffset($date)
The object-oriented version that returns the same number.
A positive number means the zone is ahead of UTC, and a negative number means it is behind. Divide by 3600 to convert seconds into hours.
Library declarations
PHP
timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime): int
Parameters
Parameter
Description
object
Required. A DateTimeZone object, usually created with timezone_open() or new DateTimeZone().
datetime
Required. A DateTime or DateTimeImmutable object that sets the moment used to find the offset. Only the point in time matters, not the time zone stored in that object.
Return Value
Return Value
Description
int
The offset from UTC in seconds, including any daylight saving adjustment.
PHP Examples
Example 1 — Offset of a Fixed Zone
India does not use daylight saving time, so its offset is always the same. We use a fixed date so the output never changes.