Note that the dst field is of boolean type, so if you are doing an identity comparison, you need to test for true or false, not 0 or 1. For example:
<?php
$timezone_abbreviations = DateTimeZone::listAbbreviations();
foreach ($timezone_abbreviations["est"] as $tz) {
echo $tz['timezone_id'];
// if ($tz['dst'] === 1) will always evaluate to false
if ($tz['dst'] === true) {
echo " (DST observed)<br />\n";
}
// Could use else here, but for illustration...
if ($tz['dst'] === false) {
echo " (DST not observed)<br />\n";
}
}
?>
DateTimeZone::listAbbreviations
(PHP 5 >= 5.2.0)
DateTimeZone::listAbbreviations — Returns associative array containing dst, offset and the timezone name
Description
staticarray DateTimeZone::listAbbreviations
( void
)
Return Values
Returns array on success or FALSE on failure.
Examples
Example #1 A timezone_abbreviations_list() example
<?php
$timezone_abbreviations = DateTimeZone::listAbbreviations();
print_r($timezone_abbreviations["acst"]);
?>
The above example will output something similar to:
Array
(
[0] => Array
(
[dst] => 1
[offset] => -14400
[timezone_id] => America/Porto_Acre
)
[1] => Array
(
[dst] => 1
[offset] => -14400
[timezone_id] => America/Eirunepe
)
[2] => Array
(
[dst] => 1
[offset] => -14400
[timezone_id] => America/Rio_Branco
)
[3] => Array
(
[dst] => 1
[offset] => -14400
[timezone_id] => Brazil/Acre
)
)
DateTimeZone::listAbbreviations
kingskippus at gmail dot com
04-Apr-2009 07:32
04-Apr-2009 07:32
