DateTimeZone::__construct
timezone_open
(PHP 5 >= 5.2.0)
DateTimeZone::__construct -- timezone_open — Creates new DateTimeZone object
설명
객체 기반 형식
public DateTimeZone::__construct()
( string $timezone
)
절차식 형식
Creates new DateTimeZone object.
반환값
Returns DateTimeZone on success. 절차식 형식 returns FALSE on failure.
오류/예외
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)
There are no user contributed notes for this page.
