Download the PHP package realodix/timezone without Composer
On this page you can find all versions of the php package realodix/timezone. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download realodix/timezone
More information about realodix/timezone
Files in realodix/timezone
Package timezone
Short Description A PHP library that provides an easy way to generate HTML select boxes for timezones.
License MIT
Homepage https://github.com/realodix/timezone
Informations about the package timezone
Realodix\Timezone
A PHP library that provides an easy way to generate HTML select boxes for timezones. It offers features to filter timezones by continent, group them, display offsets, and customize the output.
Features
- Comprehensive Timezone List: Generates a complete list of all available timezones.
- Array Representation: Retrieves timezones as an array, suitable for use in any PHP application.
- Continent-Based Grouping: Optionally groups timezones by continent for better organization.
- Flexible Filtering: Includes or excludes specific continents/groups based on your needs.
- UTC Offset Display: Displays timezone offsets (e.g., UTC+05:30) for easy reference.
Installation
You can install this package via Composer:
Project status & release process
While this library is still under development, it is well tested and should be stable enough to use in production environments.
The current releases are numbered 0.x.y
. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y
is incremented.
When a breaking change is introduced, a new 0.x
version cycle is always started. It is therefore safe to lock your project to a given release cycle, such as 0.1.*
. If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0
version.
Usage
Create HTML select box
Output:
Create timezone list array
Output:
Filtering and Grouping Timezones
Realodix\Timezone
provides a powerful set of methods to customize the timezone list:
onlyGroups(array $groups)
: Includes only the specified continent/group names. For example,$tz->onlyGroups(['America', 'Europe'])
will return only the timezones within the America and Europe continents.excludeGroups(array $groups)
: Excludes the specified continent/group names. For example,$tz->excludeGroups(['Arctic'])
will omit all timezones from Arctic.flatten()
: Flattens the timezone list, removing the continental grouping.omitOffset()
: Removes the UTC offset from the displayed timezone names.
Timezone Groups
The onlyGroups()
and excludeGroups()
methods utilize timezone groups to filter the list. Here are the available groups:
- General: For the
UTC
timezone. - Africa
- America
- Antarctica
- Arctic
- Asia
- Atlantic
- Australia
- Europe
- Indian
- Pacific
Explanation: Timezones are organized into groups, mainly based on continents. The General
group contains only the UTC
timezone. You can use these groups with the filtering methods.
Examples:
License
This package is licensed using the MIT License.