ixnode/php-timezone

PHP 时区 - 这个库可以将不同的时区字符串进行转换。

0.1.20 2024-05-24 00:16 UTC

This package is auto-updated.

Last update: 2024-09-24 01:00:34 UTC


README

这个库可以将不同的时区字符串进行转换。

用法

use Ixnode\PhpTimezone\Timezone;

从给定的时区获取国家代码。

print (new Timezone('Europe/Berlin'))->getCountryCode();
// (string) "DE"

从给定的时区获取英文国家名称。

print (new Timezone('Europe/Berlin'))->getCountryName();
// (string) "Germany"

从给定的时区获取德文国家名称。

use Ixnode\PhpTimezone\Constants\Locale

print (new Timezone('Europe/Berlin'))->getCountryName(Locale::DE_DE);
// (string) "Deutschland"

获取不同语言下的某些地区语言名称

use Ixnode\PhpTimezone\Constants\Locale
use Ixnode\PhpTimezone\Constants\LocaleTranslation

print LocaleTranslation::DE_DE[Locale::DE_DE];
// (string) "Deutsch (Deutschland)"
print LocaleTranslation::DE_DE[Locale::ES_ES];
// (string) "Alemán (Alemania)"
print LocaleTranslation::NN_NO[Locale::IT_IT];
// (string) "Norvegese nynorsk (Norvegia)"

等等。

获取不同语言下的某些语言名称

use Ixnode\PhpTimezone\Constants\Language

print Language::DE['de'];
// (string) "Deutsch"
print Language::DE['sv'];
// (string) "Tyska"
print Language::SV['en'];
// (string) "Swedish"

等等。

安装

composer require ixnode/php-timezone
vendor/bin/php-timezone -V
php-timezone 0.1.0 (12-19-2022 01:17:26) - Björn Hempel <bjoern@hempel.li>

开发

git clone git@github.com:ixnode/php-timezone.git && cd php-timezone
composer install
composer test

许可证

此工具遵循 MIT 许可证 - 详细信息请参阅LICENSE 文件。