class DateTimeZone (View source)

Representation of time zone

Constants

AFRICA

AMERICA

ANTARCTICA

ARCTIC

ASIA

ATLANTIC

AUSTRALIA

EUROPE

INDIAN

PACIFIC

UTC

ALL

ALL_WITH_BC

PER_COUNTRY

Methods

__construct(string $timezone)

Creates new DateTimeZone object

string
getName()

Returns the name of the timezone

array|false
getLocation()

Returns location information for a timezone

int
getOffset(DateTimeInterface $datetime)

Returns the timezone offset from GMT

array|false
getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = 2147483647)

Returns all transitions for the timezone

static array
listAbbreviations()

Returns associative array containing dst, offset and the timezone name

static array|false
listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, string $countryCode = null)

Returns a numerically indexed array with all timezone identifiers

void
__wakeup()

No description

static DateTimeZone
__set_state(array $array)

No description

array
__serialize()

No description

void
__unserialize(array $data)

No description

Details

__construct(string $timezone)

Creates new DateTimeZone object

Creates a new DateTimeZone object.

Parameters

string $timezone

One of the supported timezone names, an offset value (+0200), or a timezone abbreviation (BST).

Exceptions

DateInvalidTimeZoneException

string getName()

Returns the name of the timezone

Return Value

string

Depending on zone type, UTC offset (type 1), timezone abbreviation (type 2), and timezone identifiers as published in the IANA timezone database (type 3), the descriptor string to create a new DateTimeZone object with the same offset and/or rules. For example 02:00, CEST, or one of the timezone names in the list of timezones.

array|false getLocation()

Returns location information for a timezone

Return Value

array|false

Array containing location information about timezone or false on failure.

int getOffset(DateTimeInterface $datetime)

Returns the timezone offset from GMT

Parameters

DateTimeInterface $datetime

DateTime that contains the date/time to compute the offset from.

Return Value

int

Returns time zone offset in seconds.

array|false getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = 2147483647)

Returns all transitions for the timezone

Parameters

int $timestampBegin

Begin timestamp.

int $timestampEnd

End timestamp.

Return Value

array|false

Returns a numerically indexed array of transition arrays on success, or false on failure. DateTimeZone objects wrapping type 1 (UTC offsets) and type 2 (abbreviations) do not contain any transitions, and calling this method on them will return false. If timestampBegin is given, the first entry in the returned array will contain a transition element at the time of timestampBegin. Transition Array Structure Key Type Description ts int Unix timestamp time string DateTimeInterface::ISO8601_EXPANDED (PHP 8.2 and later), or DateTimeInterface::ISO8601 (PHP 8.1 and lower) time string offset int Offset to UTC in seconds isdst bool Whether daylight saving time is active abbr string Timezone abbreviation

static array listAbbreviations()

Returns associative array containing dst, offset and the timezone name

Return Value

array

Returns the array of timezone abbreviations.

static array|false listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, string $countryCode = null)

Returns a numerically indexed array with all timezone identifiers

Parameters

int $timezoneGroup

One of the DateTimeZone class constants (or a combination).

string $countryCode

A two-letter (uppercase) ISO 3166-1 compatible country code. This option is only used when timezoneGroup is set to DateTimeZone::PER_COUNTRY.

Return Value

array|false

Returns the array of timezone identifiers, or FALSE on failure. Since PHP8, always returns array.

void __wakeup()

No description

Return Value

void

static DateTimeZone __set_state(array $array)

No description

Parameters

array $array

Return Value

DateTimeZone

array __serialize()

No description

Return Value

array

void __unserialize(array $data)

No description

Parameters

array $data

Return Value

void