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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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()); 
?>

chevron_right


Output:

Asia/Kolkata

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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()); 
?>

chevron_right


Output:

Asia/Singapore

Reference
https://devdocs.io/php/datetimezone.getname



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.