Getting user's time from web revlet?
Jim Ault
jimaultwins at yahoo.com
Wed Jan 20 21:26:53 EST 2010
On Jan 20, 2010, at 6:04 PM, Sarah Reichelt wrote:
>
> As far as I know, the JavaScript Date object gives the browser's
> date & time.
> Here is a routine I have to showing a time stamp:
The original issue is that the browser does not send its system date
and time to the server so that a sever-side script can use it.
Your example is how to tell the browser to grab the time and date info
available to it and display it for the single user.
If the javascript were to update a cookie record in the spot available
for a Revlet or a web page script that gets and sets cookies, then
that info would be available for harvesting.
The other two solutions mentioned were to ask the user to press a
button to send that data, and the sneaky AJAX approach which means
you trigger a script without the user interacting to send the data
back to the same server or another or several of them. ( of course,
no one uses computers to extract info like that )
Jim Ault
Las Vegas
On Jan 20, 2010, at 6:04 PM, Sarah Reichelt wrote:
> On Wed, Jan 20, 2010 at 12:29 AM, Tim Selander
> <selander at tkf.att.ne.jp> wrote:
>> Thanks for clearing up the .irev/revlet confusion in my head.
>>
>> I've read through the thread a couple times... and it seems you
>> CANNOT get
>> the user/browser's date and time through RevServer scripts. Correct?
>>
>> Anyone have a javascript snippet they like to use to get the user's
>> date and
>> time? thanks.
>
> As far as I know, the JavaScript Date object gives the browser's
> date & time.
> Here is a routine I have to showing a time stamp:
>
> function showTimeStamp() {
> // show the current date & time in the divider bar
> var date = new Date();
> var m = date.getMinutes();
> var s = date.getSeconds();
> // add a zero in front of numbers < 10
> if (m < 10) { m = "0" + m; }
> if (s < 10) { s = "0" + s; }
>
> // format into "d/m/yyyy h:mm:ss"
> var currentDate = date.getDate() + "/" +
> (date.getMonth() + 1) + "/" +
> date.getFullYear() + " " +
> date.getHours() + ":" + m + ":" + s;
>
> $('#timestamp').text("Last step: " + currentDate);
> }
>
>
> The last line uses jQuery to display the time stamp in the tag with
> the id "timestamp", but you can also use straight JavaScript:
> document.getElementById("timestamp").innerHTML = currentDate;
>
> Note that I have the date formatted in the English/Australian style
> (d/m/y), so swap the segments around if you want American dates.
>
> HTH,
> Sarah
More information about the use-livecode
mailing list