Skip to content

Commit

Permalink
Changelog and readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebarlow committed Sep 4, 2020
1 parent 421e2ea commit e536938
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.1.0] - 2020-09-04

* Added timezoneList method to return a nice formatted array of timezones

## [2.0.0] - 2020-08-14

* Renamed namespace and package name
Expand Down
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,49 @@ This method should be used in your "views or in your API endpoints" to transform

`$format` is an optional field that defaults to standard MySQL datetime format of `YYYY-MM-DD HH:MM:SS`.

### timezoneList

This method can be used for API endpoints or within your templates to generate an array of formatted timezones. The generated array will return an associative array with the timezone as the key and a nice label with offset as the value.

```php
$timezones = new \MBarlow\Timezones\Timezones;

print_r($timezones->timezoneList());
/*
Array
(
[Pacific/Midway] => (UTC -11:00) Midway
[Pacific/Niue] => (UTC -11:00) Niue
[Pacific/Pago_Pago] => (UTC -11:00) Pago Pago
[Pacific/Honolulu] => (UTC -10:00) Honolulu
[Pacific/Rarotonga] => (UTC -10:00) Rarotonga
[Pacific/Tahiti] => (UTC -10:00) Tahiti
[Pacific/Marquesas] => (UTC -09:30) Marquesas
[America/Adak] => (UTC -09:00) Adak
[Pacific/Gambier] => (UTC -09:00) Gambier
[America/Anchorage] => (UTC -08:00) Anchorage
[America/Juneau] => (UTC -08:00) Juneau
[America/Metlakatla] => (UTC -08:00) Metlakatla
[America/Nome] => (UTC -08:00) Nome
[Pacific/Pitcairn] => (UTC -08:00) Pitcairn
[America/Sitka] => (UTC -08:00) Sitka

....
)
*/
```

```php
$timezones = new \MBarlow\Timezones\Timezones;
$list = $timezones->timezoneList();

echo '<select="timezone">';
foreach ($list as $timezone => $label) {
echo '<option value="' . $timezone . '">' . $label . '</option>';
}
echo '</select>';
```

## Laravel Extras

If you have installed the package into a Laravel application a few extra goodies are available.
Expand Down

0 comments on commit e536938

Please sign in to comment.