added RBAC
This commit is contained in:
35
lib/User/Helper/TimezoneHelper.php
Normal file
35
lib/User/Helper/TimezoneHelper.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Da\User\Helper;
|
||||
|
||||
use DateTimeZone;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use DateTime;
|
||||
|
||||
|
||||
class TimezoneHelper
|
||||
{
|
||||
/**
|
||||
* Get all of the time zones with the offsets sorted by their offset
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getAll()
|
||||
{
|
||||
$timeZones = [];
|
||||
$timeZoneIdentifiers = DateTimeZone::listIdentifiers();
|
||||
|
||||
foreach ($timeZoneIdentifiers as $timeZone) {
|
||||
$date = new DateTime('now', new DateTimeZone($timeZone));
|
||||
$offset = $date->getOffset() / 60 / 60;
|
||||
$timeZones[] = [
|
||||
'timezone' => $timeZone,
|
||||
'name' => "{$timeZone} (UTC " . ($offset > 0 ? '+' : '') . "{$offset})",
|
||||
'offset' => $offset
|
||||
];
|
||||
}
|
||||
|
||||
ArrayHelper::multisort($timeZones, 'offset', SORT_DESC, SORT_NUMERIC);
|
||||
|
||||
return $timeZones;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user