nehero/friendlytimezone
Composer 安装命令:
composer require nehero/friendlytimezone
包简介
Display timezones to your users in a friendly way using locations as names
README 文档
README
List extracted from Microsoft Time Zone Index Values.
Some regions influenced by this Stack Overflow answer.
⚠️ This package has been rewritten in version 3 to support more flexibility of working with the timezones as well as incorporating modern php features
If you are looking for the now deprecated version 2 documentation, click here
Installation
As of v3.0 this package requires PHP 8.0+
You can install the package via composer:
composer require nehero/friendlytimezone
Usage
// Illuminate\Support\Collection of Nehero\Timezone $timezones = Nehero\FriendlyTimezone\FriendlyTimezone::timezones(); // properties available to you foreach ($timezones as $timezone) { echo $timezone->friendlyName; // Saskatchewan (string) echo $timezone->timezone; // America/Regina (string) echo $timezone->offset; // -6 (int|float) echo $timezone->getFormattedOffset(); // -6:00 (string) } // common formatting for dropdowns $timezones->map(fn ($tz) => [ 'label' => "(UTC{$tz->getFormattedOffset()}) {$tz->friendlyName}"), // (UTC+6:00) Saskatchewan 'value' => $tz->timezone, // America/Regina ]); // need it in descending order? // can manipulate it however you want with // common collection or native array/iterable functions $timezones->sortByDesc(fn ($tz) => $tz->offset)->map(...);
Supported Timezones
See any missing? Pull requests and issues are welcome!
Click to view a table of all currently supported timezones
| IANA Name | Friendly Name |
|---|---|
| Pacific/Midway | Midway Island, Samoa |
| Pacific/Honolulu | Hawaii |
| America/Anchorage | Alaska |
| America/Tijuana | Pacific Time (US and Canada); Tijuana, Baja California |
| America/Edmonton | Mountain Time (US and Canada) |
| America/Chihuahua | Chihuahua, La Paz, Mazatlan |
| America/Phoenix | Arizona |
| America/Chicago | Central Time (US and Canada) |
| America/Regina | Saskatchewan |
| America/Mexico_City | Guadalajara, Mexico City, Monterrey |
| America/Managua | Central America |
| America/New_York | Eastern Time (US and Canada) |
| America/Indiana/Indianapolis | Indiana (East) |
| America/Bogota | Bogota, Lima, Quito |
| America/Caracas | Caracas |
| America/Halifax | Atlantic Time (Canada) |
| America/Argentina/San_Juan | Georgetown, La Paz, San Juan |
| America/Santiago | Santiago |
| America/Manaus | Manaus |
| America/Asuncion | Asuncion |
| America/St_Johns | Newfoundland |
| America/Sao_Paulo | Brasilia |
| America/Argentina/Buenos_Aires | Buenos Aires, Georgetown |
| America/Godthab | Greenland |
| America/Montevideo | Montevideo |
| Atlantic/South_Georgia | Mid-Atlantic |
| Atlantic/Azores | Azores |
| Atlantic/Cape_Verde | Cape Verde Islands |
| Europe/London | Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London |
| Atlantic/Reykjavik | Monrovia, Reykjavik |
| Africa/Casablanca | Casablanca |
| UTC | Coordinated Universal Time |
| Europe/Belgrade | Belgrade, Bratislava, Budapest, Ljubljana, Prague |
| Europe/Sarajevo | Sarajevo, Skopje, Warsaw, Zagreb |
| Europe/Paris | Brussels, Copenhagen, Madrid, Paris |
| Europe/Berlin | Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna |
| Africa/Lagos | West Central Africa |
| Asia/Amman | Amman |
| Asia/Beirut | Beirut |
| Africa/Cairo | Cairo |
| Europe/Minsk | Minsk |
| Europe/Helsinki | Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius |
| Europe/Athens | Athens, Bucharest, Istanbul |
| Asia/Jerusalem | Jerusalem |
| Africa/Harare | Harare, Pretoria |
| Africa/Windhoek | Windhoek |
| Europe/Moscow | Moscow, St. Petersburg, Volgograd |
| Asia/Kuwait | Kuwait, Riyadh |
| Africa/Nairobi | Nairobi |
| Asia/Baghdad | Baghdad |
| Asia/Tbilisi | Tbilisi |
| Asia/Tehran | Tehran |
| Asia/Muscat | Abu Dhabi, Muscat |
| Asia/Baku | Baku, Tbilisi, Yerevan |
| Asia/Yerevan | Yerevan |
| Indian/Mauritius | Port Louis |
| Asia/Kabul | Kabul |
| Asia/Yekaterinburg | Ekaterinburg |
| Asia/Tashkent | Tashkent |
| Asia/Karachi | Islamabad, Karachi |
| Asia/Kolkata | Chennai, Kolkata, Mumbai, New Delhi |
| Asia/Kathmandu | Kathmandu |
| Asia/Dhaka | Astana, Dhaka |
| Asia/Colombo | Sri Jayawardenepura |
| Asia/Almaty | Almaty, Novosibirsk |
| Asia/Rangoon | Yangon (Rangoon) |
| Asia/Bangkok | Bangkok, Hanoi, Jakarta |
| Asia/Krasnoyarsk | Krasnoyarsk |
| Asia/Hong_Kong | Beijing, Chongqing, Hong Kong, Urumqi |
| Asia/Kuala_Lumpur | Kuala Lumpur, Singapore |
| Asia/Taipei | Taipei |
| Australia/Perth | Perth |
| Asia/Irkutsk | Irkutsk, Ulaanbaatar |
| Asia/Seoul | Seoul |
| Asia/Tokyo | Osaka, Sapporo, Tokyo |
| Asia/Yakutsk | Yakutsk |
| Australia/Darwin | Darwin |
| Australia/Adelaide | Adelaide |
| Australia/Sydney | Canberra, Melbourne, Sydney |
| Australia/Brisbane | Brisbane |
| Australia/Hobart | Hobart |
| Asia/Vladivostok | Vladivostok |
| Pacific/Guam | Guam, Port Moresby |
| Asia/Magadan | Magadan, Solomon Islands, New Caledonia |
| Pacific/Fiji | Fiji, Kamchatka, Marshall Is. |
| Pacific/Auckland | Auckland, Wellington |
| Asia/Kamchatka | Petropavlovsk-Kamchatsky |
| Pacific/Tongatapu | Nuku'alofa |
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
If you have a better suggestion for any of the mapped regions, please submit a pull request and include accurate sources for the changes.
License
The MIT License (MIT). Please see License File for more information.
nehero/friendlytimezone 适用场景与选型建议
nehero/friendlytimezone 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 86.57k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2016 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「timezone」 「nehero」 「ozzie」 「ozziexsh」 「friendlytimezone」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nehero/friendlytimezone 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nehero/friendlytimezone 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nehero/friendlytimezone 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Datetime helpers for timezone handling
A custom Doctine DBAL type to use PHP DateTime objects set to the system's default timezone.
Official PHP SDK for the IPGeolocation.io IP Location API with single and bulk lookup support.
Geonames importer and models for Eloquent ORM. This repo is a fork from Yurtesen/Geonames.
Simple TimeZone PHP library (based on Scott Connerly timezone library).
Manages timezones for website users
统计信息
- 总下载量: 86.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-17