timezone_open()

timezone_open() — Alias of DateTimeZone::__construct().

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.2.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

timezone_open() is an alias of DateTimeZone::__construct(): same parameters, same return value.

Signature

timezone_open(string $timezone): DateTimeZone|false

Parameters

ParameterTypeWhat it takes
$timezonestringOne of the supported timezone names, an offset value (+0200), or a timezone abbreviation (BST).

Return value

Returns DateTimeZone on success. Procedural style returns false on failure.

Example

A runnable snippet:

$d = new DateTimeImmutable("2022-06-02 15:44:48 UTC"); $timezones = [ 'Europe/London', 'GMT+04:45', '-06:00', 'CEST' ]; foreach ($timezones as $tz) { $tzo = new DateTimeZone($tz); $local = $d->setTimezone($tzo); echo $local->format(DateTimeInterface::RFC2822 . ' — e') . "\n"; }

Output:

Thu, 02 Jun 2022 16:44:48 +0100 — Europe/London Thu, 02 Jun 2022 20:29:48 +0445 — +04:45 Thu, 02 Jun 2022 09:44:48 -0600 — -06:00 Thu, 02 Jun 2022 17:44:48 +0200 — CEST

All PHP 8.5 built-in functions

Reference card built from the PHP manual page timezone_open() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.