This patch allows visitors to your site to choose their time zone. Times listed on RecentChanges and other category pages will appear in their time zone, rather than the server time zone. In addition, you can choose a default time zone for users who haven't set the option.

  1. Add the following line to the top of template_prefs in template/prefs.php:
    global $TimeZoneOff;
  2. Add the code listed below to template/prefs.php, immediately after the line containing "RecentChanges".
  3. Add the code listed below to lib/init.php, immediately after the line that sets $HistMax.
  4. Add the code listed below to config.php.
  5. Change html_time and html_timestamp, in parse/html.php, to read as indicated below.
  6. Add $tzoff to the list of global variables in the preamble of action_prefs in action/prefs.php.
  7. Add the code listed below to action/prefs.php, immediately before the line that calls setcookie.

template/prefs.php (snip)

  Choose your current time here, so the server may figure out what time zone
  you are in.<br /><br />
  <select name="tzoff">
<?php
  for($i = -23.5 * 60; $i <= 23.5 * 60; $i += 30)
  {
?>
<option value="<?php print $i; ?>"<?php if($i == $TimeZoneOff) { print ' selected="selected"'; } ?>><?php
    print date('Y-m-d H:i', time() + $i * 60);
?></option>
<?php
  }
?>
  </select><br /><br />

lib/init.php (snip)

  if(ereg("tzoff=([[:digit:]]+)", $prefstr, $result))
    { $TimeZoneOff = $result[1]; }

config.php

// Default time zone offset (in minutes) for visitors who haven't yet set their
//   preferences.
$TimeZoneOff = 0;

parse/html.php

function html_time($timestamp)
{
  global $TimeZoneOff;
  if($timestamp == '') { return 'never'; }
  $time = mktime(substr($timestamp, 8, 2),  substr($timestamp, 10, 2),
                 substr($timestamp, 12, 2), substr($timestamp, 4, 2),
                 substr($timestamp, 6, 2),  substr($timestamp, 0, 4));
  return date('D, d M Y H:i:s', $time + $TimeZoneOff * 60);
}

function html_timestamp($timestamp)
{
  global $TimeZoneOff;
  $time = mktime(substr($timestamp, 8, 2),  substr($timestamp, 10, 2),
                 substr($timestamp, 12, 2), substr($timestamp, 4, 2),
                 substr($timestamp, 6, 2),  substr($timestamp, 0, 4));
  return date('Y.m.d H:i:s', $time + $TimeZoneOff * 60);
}

action/prefs.php

    if(strcmp($tzoff, "") != 0)
      { $value = $value . "&amp;tzoff=$tzoff"; }