PHP | DateTimeZone::getName() Function
The DateTimeZone::getName() function is an inbuilt function in PHP which is used to return the name of the created timezone.
Syntax:
DateTimeZone::getName()
Parameters: This function does not accept any parameter.
Return Values:: This function return the name of the created timezone.
Below programs illustrate the DateTimeZone::getName() function:
Program 1:
<?php // PHP program to illustrate DateTimeZone::getName() // function // Initialising a timezone $timeZone = "Asia/Kolkata"; // Creating DateTimeZone() object with // the above timezone $DatetimeZone = new DateTimeZone($timeZone); // Getting the name of timezone print_r($DatetimeZone->getName()); ?> |
Output:
Asia/Kolkata
Program 2:
<?php // PHP program to illustrate DateTimeZone::getName() // function // Creating DateTimeZone() object with // a specific timezone $DatetimeZone = new DateTimeZone("Asia/Singapore"); // Getting the name of timezone print_r($DatetimeZone->getName()); ?> |
Output:
Asia/Singapore
Reference
https://devdocs.io/php/datetimezone.getname
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 | value() Function
- D3.js | d3.min() function
- PHP | Ds\Set add() Function
- D3.js | d3.hcl() Function
- p5.js | nfs() Function
- p5.js | nf() Function
- CSS | rgb() Function
- PHP | Ds\Set first() Function
- p5.js | nfc() function
- PHP | Ds\Map first() Function
- PHP Ds\Map sum() Function
- p5.js | nfp() 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.


