DateTime::getOffset
DateTimeImmutable::getOffset
DateTimeInterface::getOffset
date_offset_get
(PHP 5 >= 5.2.0)
DateTime::getOffset -- DateTimeImmutable::getOffset -- DateTimeInterface::getOffset -- date_offset_get — Returns the timezone offset
Descripción
Estilo orientado a objetos
public int DateTime::getOffset
( void
)
public int DateTimeImmutable::getOffset
( void
)
public int DateTimeInterface::getOffset
( void
)
Estilo por procedimientos
Returns the timezone offset.
Parámetros
-
object -
Estilo por procesos solamente: Un objeto DateTime es devuelto por date_create()
Valores devueltos
Returns the timezone offset in seconds from UTC on success
o FALSE en caso de error.
Ejemplos
Ejemplo #1 DateTime::getOffset() example
Estilo orientado a objetos
<?php
$winter = new DateTime('2010-12-21', new DateTimeZone('America/New_York'));
$summer = new DateTime('2008-06-21', new DateTimeZone('America/New_York'));
echo $winter->getOffset() . "\n";
echo $summer->getOffset() . "\n";
?>
Estilo por procedimientos
<?php
$winter = date_create('2010-12-21', timezone_open('America/New_York'));
$summer = date_create('2008-06-21', timezone_open('America/New_York'));
echo date_offset_get($winter) . "\n";
echo date_offset_get($summer) . "\n";
?>
El resultado de los ejemplos serían:
-18000 -14400
Note: -18000 = -5 hours, -14400 = -4 hours.
There are no user contributed notes for this page.
