Create new DateTime object from null date/time in the specified time zone in PHP

Description

The following code shows how to create new DateTime object from null date/time in the specified time zone.

Example


<?php// ww  w  .  j a  va2 s .c  o  m
// Current date/time in the specified time zone.
$date = new DateTime(null, new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "\n";

?>

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