baspa/laravel-timezones
最新稳定版本:v1.3.3
Composer 安装命令:
composer require baspa/laravel-timezones
包简介
Laravel package to generate arrays of available timezones to be used in lists.
README 文档
README
Laravel package to generate arrays of available timezones to be used in lists.
The Laravel Timezones package is a convenient solution for Laravel developers who need to include a dropdown menu of timezones in their applications. This package simplifies the process of incorporating a timezone selection feature, saving developers valuable time and effort.
Installation
You can install the package via composer:
composer require baspa/laravel-timezones
Usage
Timezones grouped by continent
use Baspa\Timezones\Facades\Timezones; // $groupedTimezones = Timezones::toArray(grouped: true);
All timezones
use Baspa\Timezones\Facades\Timezones; // $timezones = Timezones::toArray();
Exclude continents
use Baspa\Timezones\Facades\Timezones; // $timezones = Timezones::excludeContinents(['Africa', 'America']) ->toArray();
Show offset
$timezones = Timezones::showOffset()->toArray(); // or $timezones = Timezones::showOffset(showOffset: false)->toArray();
Include general timezones
To include general timezones like GMT or UTC use the includeGeneral method.
$timezones = Timezones::includeGeneral()->toArray();
Show country names
To include country names alongside timezone labels use the showCountry method. This uses PHP's built-in timezone data combined with the league/iso3166 package to provide accurate country names.
// Basic usage with country names $timezones = Timezones::showCountry()->toArray(); // Output: "Amsterdam (Netherlands)" // Combined with other methods $timezones = Timezones::showCountry() ->showOffset(false) ->toArray(); // Output: "Amsterdam (Netherlands)" // With full continent names preserved $timezones = Timezones::showCountry()->toArrayWithContinents(); // Output: "Europe / Amsterdam (Netherlands)" // Grouped by continent with country names $timezones = Timezones::showCountry()->toArray(grouped: true);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 16.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-07
