ixnode / php-timezone
PHP 时区 - 这个库可以将不同的时区字符串进行转换。
0.1.20
2024-05-24 00:16 UTC
Requires
- php: ^8.0
- ixnode/php-naming-conventions: ^0.1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- ixnode/bash-version-manager: ^0.1.3
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
- povils/phpmnd: ^3.0
- rector/rector: ^0.15.1
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 文件。