JBZoo\Utils\Dates::timezone PHP Method

timezone() public static method

Return a DateTimeZone object based on the current timezone.
public static timezone ( mixed $timezone = null ) : DateTimeZone
$timezone mixed
return DateTimeZone
    public static function timezone($timezone = null)
    {
        if ($timezone instanceof DateTimeZone) {
            return $timezone;
        }
        $timezone = $timezone ?: date_default_timezone_get();
        return new DateTimeZone($timezone);
    }

Usage Example

Beispiel #1
0
 public function testTimezone()
 {
     isClass('\\DateTimeZone', Dates::timezone());
     $dtz = new DateTimeZone('America/Los_Angeles');
     same($dtz, Dates::timezone($dtz));
 }