DateTime::getOffset

DateTimeImmutable::getOffset

DateTimeInterface::getOffset

date_offset_get

(PHP 5 >= 5.2.1, PHP 7)

DateTime::getOffset -- DateTimeImmutable::getOffset -- DateTimeInterface::getOffset -- date_offset_getReturns the timezone offset

˵��

���������

public DateTime::getOffset ( void ) : int
public DateTimeImmutable::getOffset ( void ) : int
public DateTimeInterface::getOffset ( void ) : int

���̻����

Returns the timezone offset.

����

object

��Ϊ���̻������ date_create() ���ص� DateTime ���͵Ķ���

����ֵ

Returns the timezone offset in seconds from UTC on success ������ʧ��ʱ���� FALSE.

����

Example #1 DateTime::getOffset() example

���������

<?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";
?>

���̻����

<?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";
?>

�������̻������

-18000
-14400

Note: -18000 = -5 hours, -14400 = -4 hours.