📜  PHP | IntlCalendar getType()函数

📅  最后修改于: 2022-05-13 01:56:44.098000             🧑  作者: Mango

PHP | IntlCalendar getType()函数

IntlCalendar::getType()函数是PHP中的一个内置函数,用于获取字符串形式的日历类型。 “日历”是关键字的有效值。

句法:

  • 面向对象风格
    string IntlCalendar::getType( void )
  • 程序风格
    string intlcal_get_type( IntlCalendar $cal )

参数:此函数接受单个参数$cal ,其中包含 IntlCalendar 的资源。

返回值:该函数返回一个代表日历类型的字符串值。

下面的程序说明了PHP中的 IntlCalendar::getType()函数:

程序:

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());
  
?>
输出:
string(9) "gregorian"
string(7) "islamic"
string(9) "gregorian"

参考: https://www. PHP.net/manual/en/intlcalendar.gettype。 PHP