PHPackages                             nirajp/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. nirajp/timezone

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

nirajp/timezone
===============

Helps manage timezones in Laravel. Includes &lt;select&gt; form builder for timezones. Forked from camroncade/timezone

0.2(10y ago)021.0kMITPHPPHP &gt;=5.4.0

Since May 20Pushed 9y ago2 watchersCompare

[ Source](https://github.com/nirajp/timezone)[ Packagist](https://packagist.org/packages/nirajp/timezone)[ Docs](https://github.com/nirajp/timezone)[ RSS](/packages/nirajp-timezone/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

This is forked from camroncade/timezone, only difference being the timezone array, which is updated to ensure that each key appears only once.

[![Build Status](https://camo.githubusercontent.com/c656ffdb92142b7fa137abf801e884b89773b8e93bf57029f75c9615a306edb7/68747470733a2f2f7472617669732d63692e6f72672f6e6972616a702f74696d657a6f6e652e737667)](https://travis-ci.org/nirajp/timezone)

e.g. The key 'Asia/Tokyo' appeared thrice in the original array as below...

```
'(UTC+09:00) Osaka' => 'Asia/Tokyo',
'(UTC+09:00) Sapporo' => 'Asia/Tokyo',
'(UTC+09:00) Tokyo' => 'Asia/Tokyo',

```

It now appears only once...

```
'(UTC+09:00) Tokyo' => 'Asia/Tokyo',

```

Timezone Select Form Builder
============================

[](#timezone-select-form-builder)

This is a helper function that creates a select menu including timezones in human-readable format. Each underlying key is the php-friendly name for the timezone, making it easy to immediately store and use them. The array of timezones and their underlying keys were taken from the repository by [tamaspap](https://github.com/tamaspap/timezones).

Installation
------------

[](#installation)

Recommended installation of this package is through composer. Include the following in your project's `composer.json` file:

```
"require": {
	"nirajp/timezone": "0.1"
}

```

Next, update Composer from the Terminal:

```
composer update

```

Once this operation completes, the final step is to add the service provider. Open `config/app.php`, and add a new item to the service providers array.

```
'Camroncade\Timezone\TimezoneServiceProvider'

```

Now it's ready for use!

Usage
-----

[](#usage)

### Timezone Convert Helper Functions

[](#timezone-convert-helper-functions)

The package includes two helper functions that make it easy to deal with displaying and storing timezones, `convertFromUTC()` and `convertToUTC()`:

Each function accepts two required parameters and a third optional parameter dealing with the format of the returned timestamp.

```
convertFromUTC($timestamp, $timezone, $format);
convertToUTC($timestamp, $timezone, $format);

```

The first parameter accepts a timestamp, the second accepts the name of the timezone that you are converting to/from. The option values associated with the timezones included in the select form builder can be plugged into here as is. Alternatively, you can use any of [PHP's supported timezones](http://php.net/manual/en/timezones.php).

The third parameter is optional, and default is set to `'Y-m-d H:i:s'`, which is how Laravel natively stores datetimes into the database (the `created_at` and `updated_at` columns).

### Select Form Builder

[](#select-form-builder)

The package also includes a helper function for the creation of the select option. This is created by calling `Timezone::selectForm()`.

The method selectForm accepts four optional parameters, `string selected`, `placeholder`, `array formAttributes`, and `array optionAttributes`. An example of it's use is shown below:

```
$selected = 'US/Central';
$placeholder = 'Select a timezone';
$formAttributes = array('class' => 'swegForm', 'style' => 'float:left;', 'name' => 'timezone');
$optionAttributes = array('customValue' => 'true');

Timezone::selectForm($selected, $placeholder, $formAttributes, $optionAttributes);

```

Note that the `$selected` parameter matches the string to the values on each option, not the display text. The paratmeters `$formAttributes` and `$optionAttributes` can be used for styling, roles, and generally anything you need. This is useful for applying Twitter Bootstrap styling.

Simply returning `Timezone::selectForm()` will output the following:

```

(UTC-11:00) Midway Island
(UTC-11:00) Samoa
(UTC-10:00) Hawaii
(UTC-09:00) Alaska
(UTC-08:00) Pacific Time (US &amp; Canada)
(UTC-08:00) Tijuana
(UTC-07:00) Arizona
(UTC-07:00) Chihuahua
(UTC-07:00) Mazatlan
(UTC-07:00) Mountain Time (US &amp; Canada)
(UTC-06:00) Central America
(UTC-06:00) Central Time (US &amp; Canada)
(UTC-06:00) Mexico City
(UTC-06:00) Monterrey
(UTC-06:00) Saskatchewan
(UTC-05:00) Bogota
(UTC-05:00) Eastern Time (US &amp; Canada)
(UTC-05:00) Indiana (East)
(UTC-05:00) Lima
(UTC-04:00) Atlantic Time (Canada)
(UTC-04:30) Caracas
(UTC-04:00) La Paz
(UTC-04:00) Santiago
(UTC-03:30) Newfoundland
(UTC-03:00) Brasilia
(UTC-03:00) Buenos Aires
(UTC-03:00) Greenland
(UTC-02:00) Mid-Atlantic
(UTC-01:00) Azores
(UTC-01:00) Cape Verde Is.
(UTC+00:00) Casablanca
(UTC+00:00) Greenwich Mean Time : Dublin
(UTC+00:00) Lisbon
(UTC+00:00) London
(UTC+00:00) Monrovia
(UTC+00:00) UTC
(UTC+01:00) Amsterdam
(UTC+01:00) Belgrade
(UTC+01:00) Berlin
(UTC+01:00) Bratislava
(UTC+01:00) Brussels
(UTC+01:00) Budapest
(UTC+01:00) Copenhagen
(UTC+01:00) Ljubljana
(UTC+01:00) Madrid
(UTC+01:00) Paris
(UTC+01:00) Prague
(UTC+01:00) Rome
(UTC+01:00) Sarajevo
(UTC+01:00) Skopje
(UTC+01:00) Stockholm
(UTC+01:00) Vienna
(UTC+01:00) Warsaw
(UTC+01:00) West Central Africa
(UTC+01:00) Zagreb
(UTC+02:00) Athens
(UTC+02:00) Bucharest
(UTC+02:00) Cairo
(UTC+02:00) Harare
(UTC+02:00) Helsinki
(UTC+02:00) Istanbul
(UTC+02:00) Jerusalem
(UTC+02:00) Pretoria
(UTC+02:00) Riga
(UTC+02:00) Sofia
(UTC+02:00) Tallinn
(UTC+02:00) Vilnius
(UTC+03:00) Baghdad
(UTC+03:00) Kuwait
(UTC+03:00) Minsk
(UTC+03:00) Nairobi
(UTC+03:00) Riyadh
(UTC+03:00) Volgograd
(UTC+03:30) Tehran
(UTC+04:00) Baku
(UTC+04:00) Moscow
(UTC+04:00) Muscat
(UTC+04:00) Tbilisi
(UTC+04:00) Yerevan
(UTC+04:30) Kabul
(UTC+05:00) Karachi
(UTC+05:30) Kolkata
(UTC+05:30) Mumbai
(UTC+05:45) Kathmandu
(UTC+06:00) Almaty
(UTC+06:00) Dhaka
(UTC+06:00) Ekaterinburg
(UTC+06:30) Rangoon
(UTC+07:00) Bangkok
(UTC+07:00) Jakarta
(UTC+07:00) Novosibirsk
(UTC+08:00) Chongqing
(UTC+08:00) Hong Kong
(UTC+08:00) Krasnoyarsk
(UTC+08:00) Kuala Lumpur
(UTC+08:00) Perth
(UTC+08:00) Singapore
(UTC+08:00) Taipei
(UTC+08:00) Ulaan Bataar
(UTC+08:00) Urumqi
(UTC+09:00) Irkutsk
(UTC+09:00) Seoul
(UTC+09:00) Tokyo
(UTC+09:30) Adelaide
(UTC+09:30) Darwin
(UTC+10:00) Brisbane
(UTC+10:00) Canberra
(UTC+10:00) Guam
(UTC+10:00) Hobart
(UTC+10:00) Melbourne
(UTC+10:00) Port Moresby
(UTC+10:00) Sydney
(UTC+10:00) Yakutsk
(UTC+11:00) Vladivostok
(UTC+12:00) Auckland
(UTC+12:00) Fiji
(UTC+12:00) International Date Line West
(UTC+12:00) Kamchatka
(UTC+12:00) Magadan
(UTC+13:00) Nuku'alofa

```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.6% 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 ~350 days

Total

2

Last Release

3712d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c9b34b220f66ccd55df233958cf0948bed6c2f395d9730475d3b26d092baa309?d=identicon)[nirajp](/maintainers/nirajp)

---

Top Contributors

[![camroncade](https://avatars.githubusercontent.com/u/5819714?v=4)](https://github.com/camroncade "camroncade (12 commits)")[![kyranb](https://avatars.githubusercontent.com/u/5426926?v=4)](https://github.com/kyranb "kyranb (3 commits)")[![davidavz](https://avatars.githubusercontent.com/u/6774576?v=4)](https://github.com/davidavz "davidavz (1 commits)")[![iconjenchua](https://avatars.githubusercontent.com/u/9497419?v=4)](https://github.com/iconjenchua "iconjenchua (1 commits)")

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

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

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

244.6M137](/packages/illuminate-cookie)

PHPackages © 2026

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