PHP | timezone_location_get() Function
The timezone_location_get() function is an inbuilt function in PHP which is used to return the location information for the given timezone. The date time object is sent as a parameter to the timezone_location_get() function and it returns location information related to the timezone on success or False on failure.
Syntax:
timezone_location_get( $object )
Parameters: This function accepts single parameter $object which is mandatory. It is used to specify the DateTimeZone object.
Return Value: This function returns the location information for a given timezone on success or False on failure.
Exception: The timezone_location_get() function is an alias of DateTimeZone::getLocation() function.
Below programs illustrate the timezone_location_get() function in PHP:
Program 1:
<?php // Opening a timezone $timeZone = timezone_open("Asia/Kolkata"); // Displaying the location details of a timezone echo "Location Details of the Specified Timezone: \n"; print_r(timezone_location_get($timeZone)); ?> |
Location Details of the Specified Timezone:
Array
(
[country_code] => IN
[latitude] => 22.53333
[longitude] => 88.36666
[comments] =>
)
Program 2:
<?php // Declaring a timezone $timeZone = new DateTimeZone("Asia/Kolkata"); // Displaying the location details of a timezone echo ("Location Details of the Specified Timezone:\n"); print_r($timeZone->getLocation()); ?> |
Location Details of the Specified Timezone:
Array
(
[country_code] => IN
[latitude] => 22.53333
[longitude] => 88.36666
[comments] =>
)
Related Articles:
Reference: http://php.net/manual/en/function.timezone-location-get.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- p5.js | second() function
- D3.js | d3.map.get() Function
- p5.js | sq() function
- p5.js | abs() function
- p5.js | arc() Function
- p5.js | nf() Function
- p5.js | pow() function
- p5.js | nfs() Function
- p5.js | nfp() Function
- p5.js | nfc() function
- CSS | url() Function
- D3.js | d3.lab() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



