Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am finding a lot of confusing information with regard to date & time

I wish to display the local client time on a web page. What is the recommended
way of going about this? How does the server know the locale of the
client? Is it set by the web server from initiation data sent by the
clients browser?

Re: locale

Quoted text here. Click to load it

Easiest way is to use javascript which runs on the client machine and
thus will use the client machine time.

Re: locale

Richard wrote:

Quoted text here. Click to load it

You really have no way of knowing by using server-side scripting, as
the local time is never sent as a request header from the browser. The
usual request headers, at least from Opera (9.10) are (aside from the
request itself):
  User-Agent:  (browser details)
  Host:  (hostname/port used in the request)
  Accept:  (MIME types accepted)
  Accept-Language:  (browser language settings)
  Accept-Charset:  (character sets accepted)
  Accept-Encoding:  (encoding types accepted, such as "gzip")
  Connection:  (usually either "Keep-Alive" or "Close")

In any case, your best bet to find out the time local to the user, is
to use JavaScript (or another client-side scripting language).

However, I don't see the usefulness of showing the user's local time in
the browser, when just about all operating systems show the local time
in some corner. By default, Windows (up to and including XP, at least)
and most Linux-based desktops (KDE and Gnome) show this in the
bottom-right corner. Mac OS X shows this by default in the top-right
corner. If it's not showing in the operating system, it's because the
user has switched this setting off.

Kim André Akerø
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

Site Timeline