1. Go to this page and download the library: Download jackiedo/timezonelist 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/ */
namespace Your\Namespace;
use Jackiedo\Timezonelist\Facades\Timezonelist;
class YourClass
{
public function yourMethod()
{
$return = Timezonelist::doSomething();
}
}
namespace Your\Namespace;
use Jackiedo\Timezonelist\Timezonelist;
class YourClass
{
public function yourMethod()
{
$timezoneList = new Timezonelist;
$return = $timezoneList->doSomething();
}
}
/**
* Create a select box of timezones.
*
* @param string $name The name of the select tag
* @param null|string $selected The selected value
* @param null|array|string $attr The HTML attributes of select thag
* @param bool $htmlencode Use HTML entities for values of select tag
*
* @return string
*/
public function toSelectBox($name, $selected = null, $attr = null, $htmlencode = true);
/**
* Alias of the `toSelectBox()` method.
*
* @deprecated 6.0.0 This method name no longer matches the semantics
*/
public function create($name, $selected = null, $attr = null, $htmlencode = true);
echo Timezonelist::toSelectBox('timezone');
// Render a select tag with the name `timezone` and the `Africa/Asmara` option preselected
Timezonelist::toSelectBox('timezone', 'Africa/Asmara');
// Render tag with some HTML attributes
Timezonelist::toSelectBox('timezone', null, [
'id' => 'timezone',
'class' => 'styled',
...
]);
// Or with other method
Timezonelist::toSelectBox('timezone', null, 'id="timezone" class="styled"');
/**
* Create a timezone array.
*
* @param bool $htmlencode Use HTML entities for items
*
* @return mixed
*/
public function toArray($htmlencode = true);
/**
* Return new static to reset all config.
*
* @return $this
*/
public function reset();
// Genrate one select box, exclude two groups of timezones, Asia and Africa
$selectBox = Timezonelist::excludeGroups(['Asia', 'Africa'])->toSelectBox('timezone');
$list1 = Timezonelist::toArray(); // Two groups, Asia and Africa, will not be loaded into the result
$list2 = Timezonelist::reset()->toArray() // All groups will be loaded