Friday, October 17, 2025
HomeLanguagesPHP | IntlCalendar getTimeZone() Function

PHP | IntlCalendar getTimeZone() Function

The IntlCalendar::getTimeZone() function is an inbuilt function in PHP which is used to return the timezone object associated with this calendar.

Syntax:

  • Object oriented style
    IntlTimeZone IntlCalendar::getTimeZone( void )
  • Procedural style
    IntlTimeZone intlcal_get_time_zone( IntlCalendar $cal )

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
  
// Set the date timezone
ini_set('date.timezone', 'Asia/Calcutta');
ini_set('intl.default_locale', 'en_US');
  
// Create an instance of calendar
$calendar = IntlCalendar::createInstance();
  
// Get the object of timezone 
print_r($calendar->getTimeZone());
  
// Create new IntlGregorianCalendar object
$calendar->setTimezone(new DateTimeZone('Asia/Singapore')); 
  
// Get the object of timezone 
print_r($calendar->getTimeZone());
  
// Set the timezone
$calendar->setTimeZone('GMT+05:30');
  
// Get the object of timezone 
print_r($calendar->getTimeZone());
  
// Set the timezone
$calendar->setTimeZone(IntlTimeZone::getGMT());
  
// Get the object of timezone 
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

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS