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

date_timezone_set()

Example

Update the timezone of the DateTime object.

<?php
$date=date_create(“2013-05-25”,timezone_open(“Indian/Kerguelen”));
echo date_format($date,“Y-m-d H:i:sP”);
?>

Definition and Usage

The date_timezone_set() function updates the time zone of the DateTime object.

Syntax

date_timezone_set(object, timezone)

Parameter Values

 

Parameter

Description

object

Required. Specifies a DateTime object created by date_create(). This function modifies the object.

timezone

Required. Specifies a DateTimeZone object representing the desired time zone.

Technical Details

Return Value:

Returns the DateTime object for method chaining on success. FALSE on failure.

PHP Version:

5.2+

Changelog:

PHP 5.3: Changed the return value from NULL to DateTime on success.