date_offset_get()
date_offset_get() — Alias of DateTime::getOffset().
Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.2.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
date_offset_get() is an alias of DateTime::getOffset(): same parameters, same return value.
Signature
date_offset_get(DateTimeInterface $object): int
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $object | DateTimeInterface | Procedural style only: A DateTime object returned by date_create() |
Return value
Returns the timezone offset in seconds from UTC on success.
Example
A runnable snippet:
$winter = new DateTimeImmutable('2010-12-21', new DateTimeZone('America/New_York')); $summer = new DateTimeImmutable('2008-06-21', new DateTimeZone('America/New_York')); echo $winter->getOffset() . "\n"; echo $summer->getOffset() . "\n";
Output:
-18000 -14400
All PHP 8.5 built-in functions
Reference card built from the PHP manual page date_offset_get() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.