Open In App

PHP | DateTimeZone::getName() Function

Last Updated : 11 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads