<?php
$settings
['charset'] =          'utf-8';
$settings['locale'] =           array('en_US.utf8','en','eng');
$settings['time_format'] =      '%A, %B %d, %Y, %H:%M:%S';
$settings['default_timezone'] = 'UTC';

setlocale(LC_ALL$settings['locale']);

$timezones_raw file('time_zones_complete');
foreach(
$timezones_raw as $line)
 {
  if(
trim($line)!=''$timezones[] = trim($line); 
 }

if(isset(
$_GET['tz']))
 {
  if(
in_array($_GET['tz'], $timezones))
   {
    
$timezone $_GET['tz'];
   }
  else
   {
    
$timezone_invalid true;
   }
 }
else
 {
  
$timezone $settings['default_timezone'];
 }
if(!@
date_default_timezone_set($timezone))
 {
  
$timezone_invalid true;
 }

header('Content-Type: text/html; charset='.$settings['charset']);
?><!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=<?php echo $settings['charset']; ?>">
<title>Time zones</title>
<style type="text/css">
<!--
body      { font-family:sans-serif; }
table     { border-collapse:collapse; }
td        { border:1px solid #808080; padding:7px;  }
form      { display:inline; }
.source   { font-size:small; color:#808080; }
.source a { color:#808080; }
-->
</style>
</head>

<body>

<?php if(empty($timezone_invalid)): ?>

<table>
<tr>
<td>Time zone:</td>
<td><form id="tz" action="index.php" method="get">
<div>
<select name="tz" size="1" onchange="this.form.submit()">
<?php foreach($timezones as $item): ?>
<option value="<?php echo $item?>"<?php if($timezone==$item): ?> selected="selected"<?php endif; ?>><?php echo $item?></option>
<?php endforeach; ?>
</select>
<noscript><input type="submit" value="&nbsp; &raquo; &nbsp;" /></noscript>
</div>
</form></td>
</tr>
<tr>
<td>Date and time:</td>
<td><?php echo strftime($settings['time_format']); ?></td>
</tr>
<tr>
<td>Timezone abbreviation:</td>
<td><?php echo date('T'); ?></td>
</tr>
<tr>
<td>Daylight saving time:</td>
<td><?php if(date('I')==1) echo 'yes'; else echo 'no'?></td>
</tr>
<tr>
<td>RFC 2822 formatted date:</td>
<td><?php echo date('r'); ?></td>
</tr>
<tr>
<td>ISO 8601 date:</td>
<td><?php echo date('c'); ?></td>
</tr>
</table>

<?php else: ?>

<p><em>Invalid time zone</em></p>

<?php endif; ?>

<p class="source"><a href="index.source.php">source</a></p>

</body>
</html>