4

PHP | DateTimeZone::getName() Function

 3 years ago
source link: https://www.geeksforgeeks.org/php-datetimezonegetname-function/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
DateTimeZone::getName() Function
Related Articles
PHP | DateTimeZone::getName() Function
  • Last Updated : 11 Oct, 2019

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

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

Output:

Asia/Singapore

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK