(PHP 5 >= 5.2.0, PHP 7)
DateTimeZone::__construct -- timezone_open — Creates new DateTimeZone object
객체 기반 형식
$timezone
)절차식 형식
Creates new DateTimeZone object.
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)