TimeZoneHelper::listTimeZone()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 12
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
/**
3
 * @link http://www.writesdown.com/
4
 * @copyright Copyright (c) 2015 WritesDown
5
 * @license http://www.writesdown.com/license/
6
 */
7
8
namespace common\components;
9
10
/**
11
 * List of timezones with GMT offset.
12
 *
13
 * @author Agiel K. Saputra <[email protected]>
14
 * @since 0.1.0
15
 */
16
class TimeZoneHelper
17
{
18
    /**
19
     * List of timezone as array.
20
     *
21
     * @return array
22
     */
23
    public static function listTimeZone()
24
    {
25
        $timezone = [];
26
        $timestamp = time();
27
28
        foreach (timezone_identifiers_list() as $zone) {
29
            date_default_timezone_set($zone);
30
            $timezone[$zone] = $zone . ' UTC/GMT ' . date('P', $timestamp);
31
        }
32
33
        return $timezone;
34
    }
35
}
36