PHP | IntlCalendar getType() Function

The IntlCalendar::getType() function is an inbuilt function in PHP which is used to get the calendar type in terms of string. The “calendar” is the valid value of keywords.

Syntax:

  • Object oriented style
    string IntlCalendar::getType( void )
  • Procedural style
    string intlcal_get_type( IntlCalendar $cal )

Parameters: This function accepts single parameter $cal which holds the resource of IntlCalendar.



Return Value: This function returns a string value which represents the calendar type.

Below program illustrates the IntlCalendar::getType() function in PHP:

Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?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(NULL, 'en_US');
  
// Display the calendar tyle
var_dump($calendar->getType());
  
// Create an instance of calendar
$calendar = IntlCalendar::createInstance(NULL, '@calendar=islamic');
  
// Display the calendar tyle
var_dump($calendar->getType());
  
// Creare a DateTime object
$calendar = IntlCalendar::fromDateTime('2019-03-21 09:19:29'); 
  
// Display the calendar tyle
var_dump($calendar->getType());
  
?>

chevron_right


Output:

string(9) "gregorian"
string(7) "islamic"
string(9) "gregorian"

Reference: https://www.php.net/manual/en/intlcalendar.gettype.php




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.