IntlCalendar::getLocale

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a1)

IntlCalendar::getLocaleGet the locale associated with the object

说明

面向对象风格

public IntlCalendar::getLocale(int $type): string|false

过程化风格

intlcal_get_locale(IntlCalendar $calendar, int $type): string|false

Returns the locale used by this calendar object.

参数

calendar

IntlCalendar 实例。

type

Whether to fetch the actual locale (the locale from which the calendar data originates, with Locale::ACTUAL_LOCALE) or the valid locale, i.e., the most specific locale supported by ICU relatively to the requested locale – see Locale::VALID_LOCALE. From the most general to the most specific, the locales are ordered in this fashion – actual locale, valid locale, requested locale.

返回值

A locale string 或者在失败时返回 false.

范例

示例 #1 IntlCalendar::getLocale()

<?php
$cal 
IntlCalendar::createInstance(IntlTimeZone::getGMT(), 'en_US_CALIFORNIA');
var_dump(
    
$cal->getLocale(Locale::ACTUAL_LOCALE),
    
$cal->getLocale(Locale::VALID_LOCALE)
);

以上例程会输出:

string(2) "en"
string(5) "en_US"