Open In App

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:



string IntlCalendar::getType( void )
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: 




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

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

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

Article Tags :