DateTimeZone::__construct

timezone_open

Creates new DateTimeZone object

&reftitle.description;

&style.oop;

public `DateTimeZone::__construct` `string` `timezone`

&style.procedural;

`DateTimeZone` `timezone_open` `string` `timezone`

Creates new DateTimeZone object.

&reftitle.parameters;

`timezone`

- One of timezones.

&reftitle.returnvalues;

Returns `DateTimeZone` on success. &return.falseforfailure.style.procedural;

&reftitle.errors;

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

&reftitle.examples;

### 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 />';
        }
    }
    ?>

&example.outputs;

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