>>>> I'm working a servlet and I'm trying to get the date of a
>>>> HttpServletRequest. I have tried using the getHeader(),
[quoted text clipped - 22 lines]
>
> Arne
He can ask the client for the time, but what if the client tells him it's
1973?
He could look up the IP address with one of those services that locates it
geographically and then determine the timezone from that, but that's not
reliable either (e.g. if there is a proxy involved).
An alternative to doing this on the server, though no more reliable, is to
do whatever time-related stuff needs to be done on the client using
JavaScript (if possible).
Dan.

Signature
Daniel Dyer
http://www.uncommons.org
Stanimir Stamenkov - 13 Jan 2008 23:19 GMT
Sun, 13 Jan 2008 23:10:43 -0000, /Daniel Dyer/:
> He can ask the client for the time, but what if the client tells him
> it's 1973?
He can ask the client for a time-zone, instead. And he could use a
default of some predefined time-zone for the country (if any) of the
first locale returned from |ServletRequest.getLocales()|.

Signature
Stanimir
Lew - 13 Jan 2008 23:26 GMT
> Sun, 13 Jan 2008 23:10:43 -0000, /Daniel Dyer/:
>
[quoted text clipped - 4 lines]
> default of some predefined time-zone for the country (if any) of the
> first locale returned from |ServletRequest.getLocales()|.
Which, like all client-provided information, has to be viewed as likely or
possibly correct rather than certainly correct.

Signature
Lew
Lew - 13 Jan 2008 23:24 GMT
Lew wrote:
>>> Even if the browser did send time, you couldn't rely on it. Server
>>> time is the way to go.
Arne Vajhøj wrote:
>> Depends on whether he need server or client time.
> He can ask the client for the time, but what if the client tells him
> it's 1973?
This is not such a far-fetched notion. Maybe not years off, but I've seen
problems answered on Usenet that had to do with machines being set up in a
different time zone from what its owners think they'd set up, much less what
someone with no operational control at all could guarantee.
The bottom line is that you cannot trust the clock of the client, neither its
correctness nor that it is set for the correct timezone.
This is fine if you don't care what the time is at the client, but only what
the client machine asserts. In that case it's a mistake to think of the
information as a timestamp, rather view it as a time-formatted arbitrary value.

Signature
Lew