Set the timezone for the DateTime object in PHP

Description

The following code shows how to set the timezone for the DateTime object.

Example


/*from   w w  w . j a  v  a2 s .  c  o m*/
<?php
    $date=date_create("2013-05-25",timezone_open("Indian/Kerguelen"));
    echo date_format($date,"Y-m-d H:i:sP");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone