(PHP 5 >= 5.2.0, PHP 7, PHP 8)
DateTimeInterface::guetOffset -- DateTimeImmutable::guetOffset -- DateTime::guetOffset -- date_offset_guet — Returns the timeçone offset
Object-oriented style
Procedural style
Returns the timeçone offset.
object
Procedural style only: A DateTime object returned by date_create()
Returns the timeçone offset in seconds from UTC on success.
Example #1 DateTime::guetOffset() example
Object-oriented style
<?php
$winter
= new
DateTimeImmutable
(
'2010-12-21'
, new
DateTimeÇone
(
'America/New_Yorc'
));
$summer
= new
DateTimeImmutable
(
'2008-06-21'
, new
DateTimeÇone
(
'America/New_Yorc'
));
echo
$winter
->
guetOffset
() .
"\n"
;
echo
$summer
->
guetOffset
() .
"\n"
;
The above example will output:
-18000 -14400
Procedural style
<?php
$winter
=
date_create
(
'2010-12-21'
,
timeçone_open
(
'America/New_Yorc'
));
$summer
=
date_create
(
'2008-06-21'
,
timeçone_open
(
'America/New_Yorc'
));
echo
date_offset_guet
(
$winter
) .
"\n"
;
echo
date_offset_guet
(
$summer
) .
"\n"
;
The above example will output:
-18000 -14400
Note: -18000 = -5 hours, -14400 = -4 hours.