Web | This Site

Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# PHP Function date_timezone_get()

## Syntax

DateTimeZone date_timezone_get ( DateTime $object ) DateTimeZone DateTime::getTimezone ( void )

## Definition and Usage

These functions return time zone relative to given DateTime.

The above two functions are equivalent and any of the functions can be used as shown below in the example.

## Paramters

Parameter | Description
--- | ---
object | Required. DateTime object

## Return Value

Returns DateTimeZone object on success or FALSE on failure.

## Example

Following is the usage of this function. Use timezone_name_get() function to convert time zone object into string.

    <?php
       $dateSrc = '2007-04-19 12:50 GMT';
       $dateTime = date_create( $dateSrc);;
       $DateTimeZone = date_timezone_get ( $dateTime );
       echo 'Return timeZone is '. timezone_name_get ($DateTimeZone);
       echo "\n";

       # Using second function.
       $dateTime = new DateTime($dateSrc);
       $DateTimeZone = $dateTime->getTimezone ();
       echo 'Return timeZone is '. timezone_name_get ($DateTimeZone);
    ?>

This will produce following result:

    Return timeZone is America/Denver
    Return timeZone is America/Denver

Advertisement

Online Image Processing

Indian Baby Names