extract($zone);
        if ($continent == 'Africa' || $continent == 'America' || $continent == 'Antarctica' || $continent == 'Arctic' || $continent == 'Asia' || $continent == 'Atlantic' || $continent == 'Australia' || $continent == 'Europe' || $continent == 'Indian' || $continent == 'Pacific') {
            if (!isset($selectcontinent)) {
                $structure .= '<optgroup id="opt_' . $continent . '" label="' . $continent . '">' . "\n";
                /** Continent */
            } elseif ($selectcontinent != $continent) {
                $structure .= '</optgroup>' . "\n" . '<optgroup label="' . $continent . '">' . "\n";
                /** Continent */
            }
            if (isset($city) != '') {
                if (!empty($subcity) != '') {
                    $city = $city . '/' . $subcity;
                }
                $structure .= "\t<option " . ($continent . '/' . $city == $selectedzone ? 'selected="selected" ' : '') . "value=\"" . ($continent . '/' . $city) . "\">" . str_replace('_', ' ', $city) . "</option>\n";
                /** Timezone */
            } else {
                if (!empty($subcity) != '') {
                    $city = $city . '/' . $subcity;
                }
                $structure .= "\t<option " . ($continent == $selectedzone ? 'selected="selected" ' : '') . "value=\"" . $continent . "\">" . $continent . "</option>\n";
                /** Timezone */
            }
            $selectcontinent = $continent;
        }
    }
    $structure .= '</optgroup>';
    return $structure;
}
echo timezonechoice(TIMEZONE_USE);
?>
</select>
function timezones_select($selectedzone)
{
    echo '<select name="timezone">';
    function timezonechoice($selectedzone)
    {
        $all = timezone_identifiers_list();
        $i = 0;
        foreach ($all as $zone) {
            $zone = explode('/', $zone);
            $zonen[$i]['continent'] = isset($zone[0]) ? $zone[0] : '';
            $zonen[$i]['city'] = isset($zone[1]) ? $zone[1] : '';
            $zonen[$i]['subcity'] = isset($zone[2]) ? $zone[2] : '';
            $i++;
        }
        asort($zonen);
        $structure = '';
        foreach ($zonen as $zone) {
            extract($zone);
            if ($continent == 'Africa' || $continent == 'America' || $continent == 'Antarctica' || $continent == 'Arctic' || $continent == 'Asia' || $continent == 'Atlantic' || $continent == 'Australia' || $continent == 'Europe' || $continent == 'Indian' || $continent == 'Pacific') {
                if (!isset($selectcontinent)) {
                    $structure .= '<optgroup label="' . $continent . '">';
                } elseif ($selectcontinent != $continent) {
                    $structure .= '</optgroup><optgroup label="' . $continent . '">';
                }
                if (isset($city) != '') {
                    if (!empty($subcity) != '') {
                        $city = $city . '/' . $subcity;
                    }
                    $structure .= "<option " . ($continent . '/' . $city == $selectedzone ? 'selected="selected "' : '') . " value=\"" . ($continent . '/' . $city) . "\">" . str_replace('_', ' ', $city) . "</option>";
                } else {
                    if (!empty($subcity) != '') {
                        $city = $city . '/' . $subcity;
                    }
                    $structure .= "<option " . ($continent == $selectedzone ? 'selected="selected "' : '') . " value=\"" . $continent . "\">" . $continent . "</option>";
                }
                $selectcontinent = $continent;
            }
        }
        $structure .= '</optgroup>';
        return $structure;
    }
    echo timezonechoice($selectedzone);
    echo '</select>';
}
예제 #3
0
            } elseif ($letztercontinent != $continent) {
                $structure .= '</optgroup>
<optgroup label="' . $continent . '">';
            }
            // continent
            if ($city != '') {
                $structure .= "\r\n<option " . ($continent . '/' . $city == $selectedzone ? 'selected="selected "' : '') . " value=\"" . ($continent . '/' . $city) . "\">" . str_replace('_', ' ', $city) . "</option>";
            } else {
                $structure .= "\r\n<option " . ($continent == $selectedzone ? 'selected="selected "' : '') . " value=\"" . $continent . "\">" . $continent . "</option>";
            }
            //Timezone
            $letztercontinent = $continent;
        }
    }
    $structure .= '
</optgroup>';
    return $structure;
}
echo timezonechoice('Europe/Berlin');
?>
</select>
<input type="submit">
</form>
<?php 
echo $timezonechoice;
date_default_timezone_set("{$timezonechoice}");
$now = time();
// print_r( localtime(time(),true) );
// print_r( getdate() );
print date(" H:i:s");
print date(" T");