in reply to Client's time/date?
(the submitted value will look something like this: 08/18/01 17:28:35) Then you need a perl script that handles that. The perl script could re-write the page, but make sure that you also have something like that assures that the script isn't called again, and is printed right after the content-type header:<form name="theform" action="getmytime.pl"> <input type="hidden" name="user_localtime"> </form> <script language="Javascript1.2"> function set_user_localtime() { // find out if the script has already been called if ( typeof already_submitted == "undefined" ) { // create new date var datevar = new Date(); var timestring = datevar.toLocaleString(); // set the hidden field's value to the local time document.theform.user_localtime.value=timestring; // submit the form document.theform.submit(); } return 1; } </script> <body onLoad="set_user_localtime())">
Finally, you can find their offset by formatting the submitted value to be similar to perl's localtime like so:# tells the javascript that the script as already been run print "<script>var already_submitted=1;</script>";
$offset will be the difference between the server's local time and the user's local time.use CGI; $query = CGI::new; $user_localtime = $query->param("user_localtime"); @user_l = split (' ', $query); @user_time = split (':', $u_l[1]); @server_localtime = localtime; $offset = $user_time[0] - $server_localtime[2]; print $offset;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Client's time/date?
by the_mind_ (Novice) on Aug 20, 2001 at 10:12 UTC |