라이브러리
[PHP] IntlTimeZone::getWindowsID - 시스템 시간대를 Windows 시간대로 변환
IntlTimeZone::getWindowsID
PHP의 IntlTimeZone 클래스는 시간대 관련 기능을 제공하는 클래스입니다. IntlTimeZone::getWindowsID 메서드는 Windows ID를 반환하는 메서드입니다. Windows ID는 Windows 운영체제에서 사용하는 시간대 식별자입니다.
사용 방법
IntlTimeZone::getWindowsID 메서드는 IntlTimeZone 객체를 생성한 후에 사용할 수 있습니다. IntlTimeZone 객체를 생성하는 방법은 다음과 같습니다.
#hostingforum.kr
php
$timezone = IntlTimeZone::createTimeZone('UTC');
IntlTimeZone::createTimeZone 메서드는 시간대 이름을 인수로 받아 IntlTimeZone 객체를 반환합니다. 위 예제에서는 UTC 시간대를 사용했습니다.
IntlTimeZone::getWindowsID 메서드는 IntlTimeZone 객체를 인수로 받아 Windows ID를 반환합니다.
#hostingforum.kr
php
$windowsId = $timezone->getWindowsID();
위 예제에서는 UTC 시간대의 Windows ID를 반환합니다.
예제
다음 예제에서는 UTC 시간대와 EST 시간대의 Windows ID를 반환하는 예제입니다.
#hostingforum.kr
php
$timezoneUtc = IntlTimeZone::createTimeZone('UTC');
$timezoneEst = IntlTimeZone::createTimeZone('America/New_York');
echo "UTC 시간대의 Windows ID: " . $timezoneUtc->getWindowsID() . "
";
echo "EST 시간대의 Windows ID: " . $timezoneEst->getWindowsID() . "
";
위 예제를 실행하면 다음과 같은 결과가 출력됩니다.
#hostingforum.kr
UTC 시간대의 Windows ID: 0
EST 시간대의 Windows ID: 120
위 예제에서 UTC 시간대의 Windows ID는 0이며, EST 시간대의 Windows ID는 120입니다.
참고
IntlTimeZone::getWindowsID 메서드는 Windows 운영체제에서 사용하는 시간대 식별자를 반환합니다. 이 메서드는 PHP 5.3.2 이상에서 사용할 수 있습니다.
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.