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

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP timezone_location_get() Function Usage and Example

PHP Date & Time Functions 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 and latitude/Longitude and comments.

Syntax

timezone_location_get( DateTimeZone $object );

Parameter

NumberParameters and Description
1

Object (required)

The DateTimeZone object returned by timezone_open()

Return Value

An array containing information about the timezone location, or False on failure.

PHP Version

This function was initially introduced in PHP version5.3.0 was introduced and is available for 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 Functions Manual