DateTimeZone
DateTimeZone::getLocation
DateTimeZone
PHP Manual

# DateTimeZone::__construct

(PHP 5 >= 5.2.0)

DateTimeZone::__construct — Creates new DateTimeZone object

### Описание

DateTimeZone::__construct ( string `$timezone` )

Creates new DateTimeZone object.

### Список параметров

`timezone`

  One of timezones.

### Возвращаемые значения

Returns DateTimeZone on success.

### Errors/Exceptions

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

### Примеры

Пример #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)

DateTimeZone
DateTimeZone::getLocation
DateTimeZone
PHP Manual