PHP code example of jessedp / php-timezones

1. Go to this page and download the library: Download jessedp/php-timezones library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jessedp / php-timezones example snippets


Timezones::create($name, $selected, $opts);

Timezones::create('timezone');

Timezones::create('timezone', 'Asia/Ho_Chi_Minh');

Timezones::create('timezone', null,
            ['attr'=>[
             'id'    => 'my_id',
             'class' => 'form-control'
            ]
        ]);

Timezones::create('timezone',null,
                    ['attr'=>['class'=>'form-control'],
                    'with_regions'=>true,
                    'regions'=>['Africa','America']
                    ])

$timezone_list = Timezones::toArray();

    Timezones::convertFromUTC($timestamp, $timezone, $format);
    Timezones::convertToUTC($timestamp, $timezone, $format);
bash
$ composer  ^0.2.0 for jessedp/php-timezones
./composer.json has been updated
    ...

html
<select name="timezone">
  ...
  <option value="Africa/Abidjan">(GMT/UTC + 00:00) Abidjan</option>
  <option value="Africa/Accra">(GMT/UTC + 00:00) Accra</option>
  ...
</select>
html
<select name="timezone" class="form-control">
  <optgroup label="Africa">
    <option value="Africa/Addis_Ababa">
      (GMT/UTC + 03:00)&nbsp;&nbsp;&nbsp;&nbsp;Addis Ababa
    </option>
    <option value="Africa/Asmara">
      (GMT/UTC + 03:00)&nbsp;&nbsp;&nbsp;&nbsp;Asmara
    </option>
    ...
  </optgroup>
  <optgroup label="America">
    ...
    <option value="America/Noronha">
      (GMT/UTC − 02:00)&nbsp;&nbsp;&nbsp;&nbsp;Noronha
    </option>
    ...
    <option value="America/Argentina/Buenos_Aires">
      (GMT/UTC − 03:00)&nbsp;&nbsp;&nbsp;&nbsp;Argentina/Buenos Aires
    </option>
    ...
    <option value="America/New_York">
      (GMT/UTC − 05:00)&nbsp;&nbsp;&nbsp;&nbsp;New York
    </option>
    ...
  </optgroup>
</select>