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
Example
<?php
$dateTime = date_create(‘2000-01-01’);
$dateTimeZone = timezone_open(‘Australia/Perth’);
print_r( timezone_offset_get($dateTimeZone, $dateTime) );
?>
Output
28800
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
Example
<?php
$date = date_create(‘2007-05-17’);
$timezone = timezone_open ( ‘Australia/Perth’ );
date_timezone_set( $date, $timezone );
$dateTimeZone = date_timezone_get($date);
echo ‘TimeZone is ‘. timezone_name_get($dateTimeZone);
?>
Output
TimeZone is Australia/Perth
It returns the name of the timezone
Example
<?php
$date = new DateTime(‘2007-05-17’);
$timezone = timezone_open ( ‘Australia/Perth’ );
$date->setTimezone( $timezone );
echo ‘TimeZone is ‘. $timezone->getName();
?>
Output
TimeZone is Australia/Perth
It Returns the timezone name from abbreviation
Example
<?php
echo timezone_name_from_abbr(“admt”);
?>
Output
Africa/Addis_Ababa
Example
<?php
echo “<pre>”;
$timezone = new DateTimeZone(“Australia/Perth”);
print_r(timezone_location_get($timezone));
?>
Output
Array
(
[country_code] => AU
[latitude] => -31.95
[longitude] => 115.85
[comments] => Western Australia – most locations
)
It returns location details of a given timezone
Example
<?php
$timezone_identifiers = timezone_identifiers_list();
for ($i=0; $i < 10; $i++)
echo $timezone_identifiers[$i].”<br />”;
?>
s
Output
Array
(
[country_code] => AU
[latitude] => -31.95
[longitude] => 115.85
[comments] => Western Australia – most locations
)
Example
<?php
$timezone_identifiers = timezone_identifiers_list();
for ($i=0; $i < 10; $i++)
echo $timezone_identifiers[$i].”<br />”;
?>
s
Output
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Zend | Magento Certified PHP | eCommerce Architect