Man Page: datetimezone.__construct
Operating Environment: php
Section: 3
DATETIMEZONE.__CONSTRUCT(3) 1 DATETIMEZONE.__CONSTRUCT(3) DateTimeZone::__construct - Creates new DateTimeZone object Object oriented styleSYNOPSISpublic DateTimeZone::__construct (string $timezone)DESCRIPTIONProcedural style DateTimeZone timezone_open (string $timezone) Creates new DateTimeZone object.PARAMETERSo $timezone - One of the supported timezone names.RETURN VALUESReturns DateTimeZone on success. Procedural style returns FALSE on failure.ERRORS/EXCEPTIONS This method throws Exception if the timezone supplied is not recognised as a valid timezone.EXAMPLESExample #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 />'; } } ?> The above example will output: DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (Mars/Phobos) DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone (Jupiter/Europa) PHP Documentation Group DATETIMEZONE.__CONSTRUCT(3)
| Related Man Pages |
|---|
| datetime.createfromformat(3) - php |
| datetime.getlasterrors(3) - php |
| datetimezone(3) - php |
| datefmt_set_timezone(3) - php |
| datetimezone.gettransitions(3) - php |
| Similar Topics in the Unix Linux Community |
|---|
| Simple rules of the UNIX.COM forums: |
| Forum Video Tutorial: How to Use Code Tags |
| UNIX.COM 2017 Year End Summary |
| New Code Tags (Syntax Highlighting) |
| Please Welcome Don Cragun as Lead Moderator |