homepage Welcome to WebmasterWorld Guest from 54.211.95.201
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
getting time-zone of visitor
using ASP-VBScript
tinsun




msg:951187
 12:04 pm on Apr 24, 2003 (gmt 0)

is there some way to get time-zone of a person viewing my webpage -- so that I can show the next page accordingly.
(using ASP-VBScript)

 

Iguana




msg:951188
 12:27 pm on Apr 24, 2003 (gmt 0)

You can do it in client side Javascript - by getting the utc date and looking at the offset from GMT at the end of the string.

I'm shocked that ASP code can't get hold of it directly but I can't see a way

txbakers




msg:951189
 1:21 pm on Apr 24, 2003 (gmt 0)

I'm shocked that ASP code can't get hold of it directly

Why be shocked? ASP works on the server. The server doesn't really know how the client machine is set.

HOWEVER, you can capture the requesters IP address and do a cross lookup to figure out their country and location, so perhaps you can do it in ASP.

Or, when your visitors register you can ask them to enter their time zone and look up timezones that way.

Iguana




msg:951190
 1:45 pm on Apr 24, 2003 (gmt 0)

I always expected to dump my client side code and use Request.ServerVariables for all the client info. Thinking about it, there really is no reason that a browser would pass it's timezone through the HTTP headers.

Looks like my client-side code will live for ever

dmorison




msg:951191
 2:44 pm on Apr 24, 2003 (gmt 0)

Hi tinsun,

You can combine Iguana's suggestion with an automatic JavaScript form submit to get the timezone back to the server, and therefore use it in subsequent pages.

Send the following code to the client, and if they have JavaScript enabled you'll get an immediate automatic POST back to "somepage.asp" with the form variable "tz" containing the users Timezone offset.

Note the manual override in case the user is not running JavaScript. You could enhance this and provide a form for the user to select their timezone if you do not get an automatic SUBMIT.

<html>

<body>

<form name='detect' method='post' action='somepage.php'>

<input type='hidden' name='tz' value='unknown'>

</form>

Detecting Timezone...

<a href='somepage.asp'>Click Here</a> if this page does not automatically redirect...

<script type='text/javascript'>

var now = new Date();

document.detect.tz.value = now.getTimezoneOffset();

document.detect.submit();

</script>

</body>

</html>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved