Skip to content

joy2362/php-time-zone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Php-Time-Zone

Latest Version MIT Licensed Build Status Total Downloads

A wrapper to enumerate PHP 7.x, 8.x timezones list.

Basics

  • Creates timezone arrays based on PHP's supported timezones with optional grouping by region
  • Lists are sorted by offset from high (+14:00) to low (-11:00)
  • Return as php arrays for whatever use your heart desires

Installation

You can install this package using Composer.

$ composer require joy2362/php-time-zone

Publish config file:

$ php artisan vendor:publish --provider="Joy2362\PhpTimezone\PhpTimeZoneServiceProvider" --tag="config"

Config

Name Default Description
DEFAULT_TIME_ZONE 'GMT' label start value support 'GMT' and 'UTC'
TIME_DIFF_SYMBOL '.' seperator between time different hour and minutes
LABEL_FIELD_NAME 'label' timezone list array key name for label
VALUE_FIELD_NAME 'value' timezone list array key name for value

Usage

1. Get all timezone list with label and value pair

TimeZone::list();

2. Get all timezone list only value

TimeZone::listWithoutLabel();

3. Get all timezone list only label

TimeZone::listWithoutValue();

4. Get timezone list by a region

TimeZone::listByRegion('Asia');

5. Get timezone label from value

TimeZone::getLabelFromValue('Asia/Dhaka');

6. Get timezone value from label

TimeZone::getValueFromLabel('(GMT +06.00) Asia/Dhaka');

7. Get region list

TimeZone::getRegions();

8. Get supported zone list

TimeZone::getSupportedTimeZone();

Changelog

Please see Changelog for more information on what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

If you discover any security-related issues, please email abdullahzahidjoy@gmail.com instead of using the issue tracker.

Thanks to

This is based off some lovely work by: