timezone_open


world apg

CREATES new DateTimeZone object.



<?php

/* - - - - - - - - - - - - - - - - -

    Object oriented style
   
   - - - - - - - - - - - - - - - - - */

public DateTimeZone::__construct str $timezone )

$timezone The supported timezone name or an offset value

?>

<?php
 
   
/* - - - - - - - - - - - - - - - - -

      Procedural style
   
   - - - - - - - - - - - - - - - - - */

DateTimeZone|false timezone_open str $timezone )

where

$timezone The supported timezone name or an offset value

?>

 $timezone 


The supported $timezone or an offset value.





A TIMEZONE basically is a region of the Earth that presents uniformity in the measurement of time for legal, commercial or social purposes.

Standard timezones can be defined by dividing the spheroidal surface of the Earth into 24 buds, with Greenwich meredian as a reference.

TIMEZONES are important in handling dates and time as well as in the preparation of calendars.

Returns DateTimeZone on success.

Procedural style returns FALSE on failure.

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



  1 EXERCISE   

<?php

$tzns01 
= [ "America/Sao_Paulo""Europe/Lisbon""Asia/Tokyo""Africa/Foo" ];

foreach(
$tzns01 as $tz)
{
    @
var_dump(timezone_open($tz));
    echo 
'<br><br>';
}

?>

  2 EXERCISE   

<?php

$tzns02 
= [ '-0300''+0200''+0900''+0000' ];

foreach(
$tzns02 as $tz)
{
    @
var_dump(timezone_open($tz));
    echo 
'<br><br>';
}

?>

  3 EXERCISE   

<?php

$tzns03 
= [ "America/Sao_Paulo"
                      
"Europe/Lisbon"
                      
"Asia/Tokyo"
                      
"Africa/Foo" ];

foreach (
$tzns03 as $tz) {
    try {
        
$foo03 = new DateTimeZone($tz);
        } catch(
Exception $e) {
        echo 
$e->getMessage() . '<br>';
        }
                          }
?>

  4 EXERCISE   

<?php

$tzns04 
= [ '-0300''+0400''+0900''+0000' ]; 

foreach(
$tzns04 as $tz

    
$tzo04 = (array)(timezone_open($tz));
    foreach(
$tzo04 as $ktz04 => $vtz04)
    {
    echo 
$ktz04 ' = ' $vtz04 '<br>';
    }
    echo 
'<br><br>'


// see the next exercise

?>

  5 EXERCISE   

<?php

$tzns04 
= [ '-0300''+0400''+0900''+0000' ]; 

foreach(
$tzns04 as $tz

        
    
$gt04 gettimeofday(false);
    foreach(
$gt04 as $kgt04 => $vgt04)
    {    
    echo 
$kgt04 ' = ' $vgt04 '<br>';
    }
    
    echo 
'<br><br>'


?>