[thelist] web and db server local time

Ken Snyder kendsnyder at gmail.com
Fri Nov 16 17:26:50 CST 2007


Jon Molesa wrote:
> AFAIK, the time is local to the server.  Browsers don't report their
> time without some kind of javascript.
> ...
Here's a way you can get browsers to report their timezone:

<form name="login" action="" method="post">
  <input type="text" name="username" value="" />
  <input type="password" name="password" value="" />
  <input type="hidden" name="minutes_offset" value="" />
  <script type="javascript" type="text/javascript">
    //<![CDATA[
    document.forms.login.minutes_offset.value = new 
Date().getTimezoneOffset();
    //]]>
  </script>
  <input type="submit" name="submit" value="Login" />
</form>


"minutes_offset" will then be posted to the server so that dates from 
and to the user can be converted.  "minutes_offset" is the offset from 
GMT/UTC time.  If the user has JavaScript disabled, then you can default 
to the server clock timezone or whatever.

- Ken Snyder



More information about the thelist mailing list