|
Posted by Philip Hallstrom on 07/13/05 21:47
> I'd like to generate a list of time zones (EST, CDT, whatever) for a popup.
>
> Seems like it should be easy...
>
> This is so the Sales guy can just plug in the time and zone of who he's
> gotta call back, and I stuff that in the database, and he gets a morning
> report of who to call.
>
> <?php
> for ($offset = 0; $offset <= 23; $offset++){
> $z = ???;
> echo "<option>$z</option>\n";
> }
> ?>
>
> What can I use for ??? to get the time zone name for offsets?
We did this for our app... we're always on FreeBSD though, but I imagine
the same files exist on Linux/others just somewhere else...
define("ZONETAB", "/usr/share/zoneinfo/zone.tab");
$fd = @fopen(ZONETAB, "r");
if (!$fd) {
print("<option value='GMT'>GMT");
} else {
while (!feof($fd)) {
$line = fgets($fd);
if (ereg("^US\t", $line)) {
list($x, $x, $tz_file, $tz_name) = explode("\t", trim($line));
print("<option value='$tz_file'>$tz_name");
}
}
fclose($fd);
}
Gives you a kind of odd format though (we needed the actual timezone file name,
not the offset), but maybe this gets you closer...
<option value='America/New_York' >Eastern Time
<option value='America/Detroit' >Eastern Time - Michigan - most locations
<option value='America/Louisville' >Eastern Time - Kentucky - Louisville area
<option value='America/Kentucky/Monticello' >Eastern Time - Kentucky - Wayne County
<option value='America/Indianapolis' >Eastern Standard Time - Indiana - most locations
<option value='America/Indiana/Marengo' >Eastern Standard Time - Indiana - Crawford County
<option value='America/Indiana/Knox' >Eastern Standard Time - Indiana - Starke County
<option value='America/Indiana/Vevay' >Eastern Standard Time - Indiana - Switzerland County
<option value='America/Chicago' >Central Time
<option value='America/Menominee' >Central Time - Michigan - Wisconsin border
<option value='America/North_Dakota/Center' >Central Time - North Dakota - Oliver County
<option value='America/Denver' >Mountain Time
<option value='America/Boise' >Mountain Time - south Idaho & east Oregon
<option value='America/Shiprock' >Mountain Time - Navajo
<option value='America/Phoenix' >Mountain Standard Time - Arizona
<option value='America/Los_Angeles' selected>Pacific Time
<option value='America/Anchorage' >Alaska Time
<option value='America/Juneau' >Alaska Time - Alaska panhandle
<option value='America/Yakutat' >Alaska Time - Alaska panhandle neck
<option value='America/Nome' >Alaska Time - west Alaska
<option value='America/Adak' >Aleutian Islands
<option value='Pacific/Honolulu' >Hawaii
Navigation:
[Reply to this message]
|