English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP timezone_location_get() Function Usage and Example

PHP Date & Time Function Manual

The timezone_location_get() function returns the location information of the timezone

Definition and Usage

The timezone_location_get() function returns the location information of the timezone, including country code, latitude/Longitude and comments.

Syntax

timezone_location_get (DateTimeZone $object);

Parameter

Serial NumberParameters and Description
1

Object (required)

DateTimeZone object returned by timezone_open()

Return Value

Array containing information about the location of the timezone, false on failure.

PHP Version

This function was originally introduced in PHP version5.3.0 introduced and can be used in all higher versions.

Online Example

DateTimeZone::getLocation() Example-

<?php
$tz = new DateTimeZone("Asia/Shanghai);
print_r($tz->getLocation());
print_r(timezone_location_get($tz));
?>
Test and See‹/›

Output Result

Array
(
    [country_code] => CN
    [latitude] => 31.23333
    [longitude] => 121.46666
    [comments] => Beijing Time
)
Array
(
    [country_code] => CN
    [latitude] => 31.23333
    [longitude] => 121.46666
    [comments] => Beijing Time
)

PHP Date & Time Function Manual