note 89136 deleted from function.timezone-name-from-abbr by danbrown
| From: | danbrown@php.net | Date: | Mon, 23 Feb 2009 21:46:02 +0000 |
| Subject: | note 89136 deleted from function.timezone-name-from-abbr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151035@lists.php.net to get a copy of this message | ||
Note Submitter: Master Tablu
----
It is probably best to include a check for daylight savings time in the proposed function:
<?php
/* Takes a GMT offset (in hours) and returns a timezone name */
function tz_offset_to_name($offset)
{
$isDst = (bool)date('I');
$offset *= 3600; // convert hour offset to seconds
$abbrarray = timezone_abbreviations_list();
foreach ($abbrarray as $abbr)
{
foreach ($abbr as $city)
{
if ((bool)$city['dst'] == $isDst && $city['offset'] ==
$offset)
{
return $city['timezone_id'];
}
}
}
return FALSE;
}
?>