update : 2015.11.03
php.shukuma.com

검색:
 
 
Creates new DateTimeZone object

DateTimeZone::__construct

timezone_open

(PHP 5 >= 5.2.0, PHP 7)

DateTimeZone::__construct -- timezone_openCreates new DateTimeZone object

설명

객체 기반 형식

public DateTimeZone::__construct ( string $timezone )

절차식 형식

DateTimeZone timezone_open ( string $timezone )

Creates new DateTimeZone object.

인수

timezone

One of the supported timezone names.

반환값

Returns DateTimeZone on success. 절차식 형식은 실패시 FALSE를 반환합니다.

오류/예외

This method throws Exception if the timezone supplied is not recognised as a valid timezone.

예제

Example #1 Catching errors when instantiating DateTimeZone

<?php
// Error handling by catching exceptions
$timezones = array('Europe/London''Mars/Phobos''Jupiter/Europa');

foreach (
$timezones as $tz) {
    try {
        
$mars = new DateTimeZone($tz);
    } catch(
Exception $e) {
        echo 
$e->getMessage() . '<br />';
    }
}
?>

위 예제의 출력:

DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (Mars/Phobos)
DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (Jupiter/Europa)