Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

PHP | IntlCalendar getType() Function

  • Last Updated : 25 Sep, 2019

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:




<?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());
  
?>
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
Recommended Articles
Page :