PHPackages                             realodix/timezone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. realodix/timezone

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

realodix/timezone
=================

A PHP library that provides an easy way to generate HTML select boxes for timezones.

v0.1.3(1mo ago)03.7k↑680%MITPHPPHP ^8.1CI passing

Since Mar 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/realodix/timezone)[ Packagist](https://packagist.org/packages/realodix/timezone)[ Docs](https://github.com/realodix/timezone)[ RSS](/packages/realodix-timezone/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (4)Dependencies (10)Versions (6)Used By (0)

Realodix\\Timezone
==================

[](#realodixtimezone)

[![PHPVersion](https://camo.githubusercontent.com/f1314f86ce41e6dc7a2d2b32419d8d7b37945e64a1f611c39a3c54312c97bc44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d3737374242342e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/f1314f86ce41e6dc7a2d2b32419d8d7b37945e64a1f611c39a3c54312c97bc44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d3737374242342e7376673f7374796c653d666c61742d737175617265)[![GitHub license](https://camo.githubusercontent.com/8c9ba9ee424ea9e85816eb69ad10f2f49775abb9d9da82c63e464c6d4143c96d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7265616c6f6469782f74696d657a6f6e653f7374796c653d666c61742d737175617265)](/LICENSE)

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
--------

[](#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
------------

[](#installation)

You can install this package via Composer:

```
composer require realodix/timezone
```

### Project status &amp; release process

[](#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](https://github.com/realodix/timezone/releases) for a list of changes introduced by each further `0.x.0` version.

Usage
-----

[](#usage)

### Create HTML select box

[](#create-html-select-box)

```
/**
 * @param string $name The name attribute of the select tag
 * @param string|null $selected The value of the option to be pre-selected
 * @param array|null $attrs Additional HTML attributes
 */
public function toSelectBox(string $name, ?string $selected = null, ?array $attrs = null): string
```

```
use Realodix\Timezone\Timezone;

$tz = new Timezone;
$attributes = ['class' => 'form-control', 'id' => 'timezone-select'];

// Generate a select box with the name "timezone", pre-selecting "America/New_York",
// and using the specified attributes.
$tz->toSelectBox('timezone', 'America/New_York', $attributes);
```

Output:

```

        (UTC+00:00) UTC

    ...

        ...
        (UTC-05:00) Nassau
        (UTC-05:00) New York
        (UTC-09:00) Nome
        ...

    ...

        (UTC+03:00) Aden
        (UTC+05:00) Almaty
        ...

    ...

```

### Create timezone list array

[](#create-timezone-list-array)

```
use Realodix\Timezone\Timezone;

$tz = new Timezone;
$tz->toArray();
```

Output:

```
[
    'UTC' => '(UTC+00:00) UTC',
    'America' => [
        'Nassau' => '(UTC-05:00) Nassau',
        'New_York' => '(UTC-05:00) New York',
        'Nome' => '(UTC-09:00) Nome'
        // ...
    ],
    // ...
]
```

### Filtering and Grouping Timezones

[](#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:**

```
use Realodix\Timezone\Timezone;

$tz = new Timezone;
// Only include timezones from the America and Europe groups.
$tz->onlyGroups(['America', 'Europe'])->toArray();

// Output:
// [
//     'America' => [
//         'Nassau' => '(UTC-05:00) Nassau',
//         'New_York' => '(UTC-05:00) New York',
//         // ...
//     ],
//     'Europe' => [
//         'London' => '(UTC+00:00) London',
//         // ...
//     ],
// ]

// Exclude timezones from the Arctic and Africa groups.
$tz->excludeGroups(['Arctic', 'Africa'])->toArray();

// Output (will not include any timezones from the Arctic or Africa groups):
// [
//     'General' => [
//         'UTC' => '(UTC+00:00) UTC'
//     ]
//     'America' => [
//         'Nassau' => '(UTC-05:00) Nassau',
//         'New_York' => '(UTC-05:00) New York',
//         // ...
//     ],
//     // ...
// ]
```

License
-------

[](#license)

This package is licensed using the [MIT License](/LICENSE).

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance94

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~147 days

Total

4

Last Release

30d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/01bfff23a3bc54204b47bee797a13a438df9156915ad177258dbd1a9f110f5b7?d=identicon)[KeiJR](/maintainers/KeiJR)

---

Top Contributors

[![realodix](https://avatars.githubusercontent.com/u/1314456?v=4)](https://github.com/realodix "realodix (14 commits)")

---

Tags

timezonetimezone-list

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/realodix-timezone/health.svg)

```
[![Health](https://phpackages.com/badges/realodix-timezone/health.svg)](https://phpackages.com/packages/realodix-timezone)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M267](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M989](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M362](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
