It creates new DateTimeZone object
Example
<?php
$date = new DateTime(‘now’, new DateTimeZone(‘Asia/Calcutta’));
$time = $date->format(‘H:i’);
echo $time;
?>
Output
17:53
It returns all transitions for the timezone
Example
<?php
echo “<pre>”;
$tz = new DateTimeZone(“Europe/London”);
$tzTransitions = $tz ->getTransitions();
print_r(array_slice($tzTransitions, 0, 2));
?>
Output
Array
(
[0] => Array
(
[ts] => -2147483648
[time] => 1901-12-13T20:45:52+0000
[offset] => 3600
[isdst] => 1
[abbr] => BST
)
[1] => Array
(
[ts] => -1691964000
[time] => 1916-05-21T02:00:00+0000
[offset] => 3600
[isdst] => 1
[abbr] => BST
)
)
It returns the version of the timezonedb
Example
<?php
echo timezone_version_get();
?>
Output
0.system
It returns the timezone offset from GMT
Example
<?php
$dateTimeZone = new DateTimeZone(‘Australia/Perth’);
echo $dateTimeZone->getOffset(new DateTime(“2000-01-01″, new DateTimezone( ‘GMT’ )));
?>
Output
28800