牛牛在线工具

IntlDateFormatter::getLocale()

收录 8868 个 PHP 函数,含用途说明与用法示例。

IntlDateFormatter::getLocale()

返回当前 IntlDateFormatter 对象的区域设置

函数名: IntlDateFormatter::getLocale() 适用版本: PHP 5 >= 5.3.0, PHP 7, PHP 8 用法: IntlDateFormatter::getLocale() 函数返回当前 IntlDateFormatter 对象的区域设置。 示例: // 创建一个 IntlDateFormatter 对象 $dateFormatter = new IntlDateFormatter( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/New_York', IntlDateFormatter::GREGORIAN ); // 获取当前对象的区域设置 $locale = $dateFormatter->getLocale(); // 打印输出区域设置 echo "当前区域设置是:" . $locale; 输出: 当前区域设置是:en_US 在上面的示例中,我们首先创建了一个 IntlDateFormatter 对象,然后使用 getLocale() 函数获取了当前对象的区域设置。最后,我们打印输出了区域设置,得到了 "en_US"。这表示当前对象的日期格式将使用英语(美国)的语言和地区设置进行格式化。