PHP 5.6.0RC3 is available

DateTimeZone::__construct

timezone_open

(PHP 5 >= 5.2.0)

DateTimeZone::__construct -- timezone_openCreates new DateTimeZone object

Descrierea

Stil obiect-orientat

public DateTimeZone::__construct ( string $timezone )

Stil procedural

DateTimeZone timezone_open ( string $timezone )

Creates new DateTimeZone object.

Parametri

timezone

One of timezones.

Valorile întoarse

Returns DateTimeZone on success. Stil procedural întoarce FALSE în caz de eșec.

Erori/Excepții

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

Exemple

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

Exemplul de mai sus va afișa:

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

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top