PHP | IntlCalendar getTimeZone() Function
Last Updated :
25 Sep, 2019
The IntlCalendar::getTimeZone() function is an inbuilt function in PHP which is used to return the timezone object associated with this calendar.
Syntax:
Parameters: This function accepts single parameter $cal which holds the resource of IntlCalendar object.
Return Value: This function returns an IntlTimeZone object associated with this calendar.
Below program illustrates the IntlCalendar::getTimeZone() function in PHP:
Program:
<?php
ini_set ( 'date.timezone' , 'Asia/Calcutta' );
ini_set ( 'intl.default_locale' , 'en_US' );
$calendar = IntlCalendar::createInstance();
print_r( $calendar ->getTimeZone());
$calendar ->setTimezone( new DateTimeZone( 'Asia/Singapore' ));
print_r( $calendar ->getTimeZone());
$calendar ->setTimeZone( 'GMT+05:30' );
print_r( $calendar ->getTimeZone());
$calendar ->setTimeZone(IntlTimeZone::getGMT());
print_r( $calendar ->getTimeZone());
?>
|
Output:
IntlTimeZone Object
(
[valid] => 1
[id] => Asia/Calcutta
[rawOffset] => 19800000
[currentOffset] => 19800000
)
IntlTimeZone Object
(
[valid] => 1
[id] => Asia/Singapore
[rawOffset] => 28800000
[currentOffset] => 28800000
)
IntlTimeZone Object
(
[valid] => 1
[id] => GMT+05:30
[rawOffset] => 19800000
[currentOffset] => 19800000
)
IntlTimeZone Object
(
[valid] => 1
[id] => GMT
[rawOffset] => 0
[currentOffset] => 0
)
Reference: https://www.php.net/manual/en/intlcalendar.gettimezone.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...