views:

333

answers:

2

I am not into web (client/server)application development, but had this question for sometime -

If some web browser (IE/Firefox) makes a connection to some website, is it possible for the web server to find out the timezone of the client, or current local time of the client place, and display the same on the page.

If yes then how is the time zone found out? Does the client play any role in this process or server alone can do this task without any input from client?

-AD

+2  A: 

Yes. Use something like:

<script type="text/javascript" language="javascript"> 
var tz =(new Date).getTimezoneOffset()/-60; 
</script>

See also:

http://www.willmaster.com/library/javascript/determining-your-visitors-time-zone.php http://www.tommylacroix.com/2008/02/25/detect-timezone-with-javascript/ http://www.webmasterworld.com/forum13/3922.htm

flesh
There are errors in your code. Try this instead: var tz =(new Date).getTimezoneOffset()/-60;
some
cheers, hangover ;)
flesh
+2  A: 

The server can not directly tell the timezone of a client connection, but a little trick you can do is use Javascript on the client side to determine the timezone and then report it back to the server in some way. This could be by setting a cookie (the server has access to the cookies), an AJAX request, or by changing a link href to insert the timezone into a GET parameter.

nickf