Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

timezone_open()

Example

Create a new DateTimeZone object and return its timezone name.

<?php
$tz=timezone_open(“Europe/Paris”);
echo timezone_name_get($tz);
?>

Definition and Usage

The timezone_open() function creates a new DateTimeZone object.

Syntax

The two functions below are equivalent and either can be used, as demonstrated in the example above.

Procedural style:

timezone_open(timezone)

Object oriented style:

DateTimeZone::__construct(timezone)

Parameter Values

 

Parameter

Description

timezone

Required. Specifies a timezone.

Tip: Consult the list of all supported timezones in PHP.

Technical Details

Return Value:

Returns the DateTimeZone object on success, or FALSE on failure.

PHP Version:

5.2+

PHP Changelog:

PHP 5.5.1: The timezone parameter now accepts offset values.