PHP | timezone_name_get() Function
The timezone_name_get() function is an inbuilt function in PHP which is used to return the name of the timezone. The date time object is sent as a parameter to the timezone_name_get() function and it returns the name of the timezone on success or False on failure.
Syntax:
string timezone_name_get( $object )
Parameters: This function accepts single parameter $object which is mandatory. It is used to specifies the DateTimeZone object.
Return Value: This function returns the name of the timezone on success or False on failure.
Exceptions: The timezone_name_get() function is an alias of DateTimeZone::getName() function.
Below programs illustrate the timezone_name_get() function in PHP:
Program 1:
<?php // Opening the timezone of America/Chicago $timezone = timezone_open("America/Chicago"); // Displaying the name of the timezone echo ("The name of the timezone is " . timezone_name_get($timezone)); ?> |
The name of the timezone is America/Chicago
Program 2:
<?php // Opening the default timezone echo ("Default time zone is " . date_default_timezone_get()); echo "\n"; // Declaring a new timezone $new_timezone = 'America/Chicago'; if( date_default_timezone_set( $new_timezone) ) { echo "New time zone is ". date_default_timezone_get(); } ?> |
Default time zone is UTC New time zone is America/Chicago
Related Articles:
- PHP | timezone_location_get() Function
- PHP | timezone_name_from_abbr() Function
- PHP | timezone_version_get() Function
Reference: http://php.net/manual/en/function.timezone-name-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 ?
- D3.js | d3.map.set() Function
- PHP | max( ) Function
- PHP | exp() Function
- D3.js | d3.min() function
- PHP | Ds\Map get() Function
- CSS | rgb() Function
- PHP | min( ) Function
- p5.js | box() Function
- p5.js | value() Function
- D3.js | d3.rgb() Function
- p5.js | int() function
- D3.js | d3.hcl() 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.



