Welcome to WebmasterWorld Guest from 54.167.86.132

Forum Moderators: ocean10000

Message Too Old, No Replies

getting time-zone of visitor

using ASP-VBScript

     

tinsun

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

Inactive Member
Account Expired

 
 


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)
12:27 pm on Apr 24, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 20, 2002
posts:889
votes: 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

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

Senior Member

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 1, 2001
posts:4392
votes: 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.

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 20, 2002
posts:889
votes: 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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 3, 2003
posts:1633
votes: 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>

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members