DateTime::getOffset
date_offset_get
(PHP 5 >= 5.2.0)
DateTime::getOffset -- date_offset_get — Returns the timezone offset
설명
객체 기반 형식
public int DateTime::getOffset
( void
)
절차식 형식
Returns the timezone offset.
인수
- object
-
절차식 전용: date_create()가 반환하는 DateTime 객체.
반환값
Returns the timezone offset in seconds from UTC on success or FALSE on failure.
예제
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 $winter->getOffset() . "\n";
echo $summer->getOffset() . "\n";
?>
위 예제들의 출력:
-18000 -14400
Note: -18000 = -5 hours, -14400 = -4 hours.
There are no user contributed notes for this page.
