https://github.com/spekulatius/silverstripe-timezones
Provides time zone data as well as a pre-populated dropdown field for SilverStripe
https://github.com/spekulatius/silverstripe-timezones
silverstripe silverstripe3 timezone
Last synced: 6 months ago
JSON representation
Provides time zone data as well as a pre-populated dropdown field for SilverStripe
- Host: GitHub
- URL: https://github.com/spekulatius/silverstripe-timezones
- Owner: spekulatius
- License: bsd-3-clause
- Created: 2015-06-14T09:13:48.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-07-06T20:50:02.000Z (over 1 year ago)
- Last Synced: 2024-11-08T05:42:00.153Z (11 months ago)
- Topics: silverstripe, silverstripe3, timezone
- Language: PHP
- Homepage: https://peterthaleikis.com
- Size: 43.9 KB
- Stars: 2
- Watchers: 3
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: license.md
Awesome Lists containing this project
README
# [SilverStripe Time zones FormField module](https://github.com/spekulatius/silverstripe-timezones)
[](https://travis-ci.org/spekulatius/silverstripe-timezones) [](https://github.com/spekulatius/silverstripe-timezones/releases) [](https://packagist.org/packages/spekulatius/silverstripe-timezones) [](https://scrutinizer-ci.com/g/spekulatius/silverstripe-timezones?branch=master) [](https://packagist.org/packages/spekulatius/silverstripe-timezones) [](https://github.com/spekulatius/silverstripe-timezones/blob/master/license.md)
Provides a reusable model and data of the time zones worldwide. In addition a
dropdown field for a time zones selection is included.### Requirements
* SilverStripe Framework 4.0
### Installation
For the installation you can either download the package, unzip it into your
project directory and run dev build manually or run the following commands in
your project directory:```
composer require spekulatius/silverstripe-timezones
./vendor/bin/sake dev/build
```The data will automatically populated on dev build.
### Provided Data
The provided data comes from PHPs built-in function [`timezone_identifiers_list()`](http://php.net/DateTimeZone.listIdentifiers).
Before the data gets saved in the db it will be prepared so its ready to be
used.### Dropdown Field
If you want to use the dropdown field you can simply add a timezone to your db
fields:```
TimeZone::class
);/**
* @return FieldList
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();// ...
$fields->addFieldToTab(
'Root.Main',
TimeZoneField::create(
'TimeZone',
'My time zone'
)
);return $fields;
}
}
```### Format of time zone
You can change the default format of the time zone in the dropdown menu by
creating a file `mysite/_config/timezone.yml` and adding e.g.```
SilverStripe\Core\Injector\Injector:
Spekulatius\TimeZones\Model\TimeZoneData:
properties:
format: '%Name (%Region)'
```You can use 'Name', 'Region' and 'Identifier' in the string and it will be
replaced proper.* [Future ideas/development, issues](https://github.com/spekulat/silverstripe-timezones/issues),
* [Contributing](https://github.com/spekulat/silverstripe-timezones/blob/master/CONTRIBUTING.md),
* [License](https://github.com/spekulat/silverstripe-timezones/blob/master/license.md)This project is supported by [bring your own ideas Ltd.](https://bringyourownideas.com). Bring Your Own Ideas Ltd. helps you to make your project ideas a reality.
[](https://bringyourownideas.com)