> So, how do you handle this? Does the browser inform the server of
> the local time in the http requests? If not, how?
>
I put something like this on the Login form to snag the TZ from the
user's browser, then set up formatters in the session (with input
parsers and output formatters) with the captured time zone. The TZ
is actually passed as a hidden field in the login form. This is
somewhat better than storing the TZ in the db because while I am
often in NY, I'm not going to always be logging in from NY.
abc
==== [ ClientTimeZone.js ] ====
// This code lifted from 'http://www.mkolar.org/javascript/
clock.html' and liberally modified
var msie = navigator.userAgent.indexOf("MSIE");
var now = new Date();
var clientTimeZoneOffset = now.getTimezoneOffset(); // = what browser
thinks is TZ; but
// MS IE version 3 gives wrong sign of TZ
// MSIE 4.0b2 shifts TZ by -1 hour
// Any other problems?
if (clientTimeZoneOffset) {
if (msie > -1) {
if (navigator.userAgent.substring(msie+5,msie+6) <= 3) {
clientTimeZoneOffset *= -1;
} else {
if (navigator.userAgent.indexOf("4.0b2") > -1) {
clientTimeZoneOffset += 60;
}
}
}
document.write('<input type="hidden" name="x-clientTimeZoneOffset"
value="' + clientTimeZoneOffset * 60 * -1 + '" />');
}
===========
(thanks to Ken Anderson who first showed me this trick)
__alex cone
ceo codefab inc
212 465-8484 x101
ab..odefab.com
http://www.codefab.com
If you are not living on the edge, you are taking up too much space.
This archive was generated by hypermail 2.0.0 : Sat Oct 06 2007 - 13:46:56 EDT