navcan
Posts: 61
|
| Posted: 12/23/2006, 9:40 PM |
|
ASP 3.0, IIS 6, SQL 2000
I would like to capture visitor's local computer time in a hidden datetime field when the form is submitted, but when I use Now() it captures the server datetime which maybe different from visitor's local time. Does anybody know how to do this in vbscript?
Or if I capture visitor's local time using javascript, how to pass it to vbscript?
Thanks.
|
 |
 |
Edd
Posts: 547
|
| Posted: 12/24/2006, 5:16 PM |
|
There are various methods -
I think the simplest is to create 2 hidden fields on the form.
Using Javascript:
On the Onload event populate the first field with the date and time.
On the Submit button populate the second field with the date and time.
At the server take one from the other.
This does not allow for refreshing of pages.
Edd
_________________
Accepting and instigating change are life's challenges.
http://www.syntech.com.au |
 |
 |
marcwolf
Posts: 361
|
| Posted: 01/10/2007, 9:17 PM |
|
I did something similar but with a different twist.
We had an application that was world wide and we wanted ALL of the data to be stored as GMT.
In the global.asa of the server we ran a little javascript that got the timezoneoffset value.
On the login page of the application we did the same. Thus we had the difference that we needed to add of subtract for any date to either store it as a GMT value or to display it as a user local value.
So the use of hidden fields and javascript to capture the browsers date and time works very well.
Only hope that the user had the computer clock set correctly :>
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 01/11/2007, 7:45 AM |
|
Dave,
As I understand Navcan's question, it is exactly the one you reply on.
Edd, is merely counting the time spend on your server by subtracting one from the other.
My question is, out of mere interest, how did you get the users local time?
I have, because of nacans question, tried to find any reference in the HHTP variables to either the users local time or even his timezone.
Have googled for a solution but found no satisfying answer.
Apperently you know how, would you like to enlighten me (us)?
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 01/11/2007, 2:47 PM |
|
Hi Walter
This is the piece of code I use on the client side
var d, tz;
d = new Date();
tz = d.getTimezoneOffset();
document.forms["Login"].timezoneoffset.value = tz;
Now - the hidden file timezone offset now contains the difference between GMT and the users browser.
For the users date/time just use the variable 'd'
Hope it helps.
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
wkempees
|
| Posted: 01/11/2007, 3:07 PM |
|
Thanks Dave.
I just needed to know, navcan will surely appreciate it.
So there is definitely no hidden info in the users browser/session that can
be captured servers side, relating to time and/or timezone
We can get his/her ipnr, browser used even the language but not this.
Walter
|
|
|
 |
|