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
It returns numerically index array with all timezone identifiers
Example
<?php
$timezone_identifiers = DateTimeZone::listIdentifiers();
for ($i=0; $i < 10; $i++)
echo $timezone_identifiers[$i].”<br />”;
?>
Output
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Example
<?php
echo “<pre>”;
$timezone = timezone_abbreviations_list();
print_r($timezone[‘admt’]);
?>
Output
Array
(
[0] => Array
(
[dst] =>
[offset] => 9320
[timezone_id] => Africa/Addis_Ababa
)
[1] => Array
(
[dst] =>
[offset] => 9320
[timezone_id] => Africa/Asmara
)
[2] => Array
(
[dst] =>
[offset] => 9320
[timezone_id] => Africa/Asmera
)
)
It returns associative array containing dst, offset and the timezone name
Example
<?php
echo “<pre>”;
$ta = DateTimeZone::listAbbreviations();
print_r($ta[“burt”]);
?>
Output
Array
(
[0] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Kolkata
)
[1] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Calcutta
)
[2] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Dacca
)
[3] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Dhaka
)
[4] => Array
(
[dst] =>
[offset] => 23400
[timezone_id] => Asia/Rangoon
)
)
It returns current Unix timestamp
Example
<?php
echo time();
?>
Output
1335343399
Zend | Magento Certified PHP | eCommerce Architect