jQuery CountDown time-limit strange variations...

Hi there,

I store the exact (server) time each user "starts" a test in a SQLserver database, then I add 40minutes to create the timeLimit for the user to FINISH his/her test.

The following code is the "until"  JQuery CountDown feature, EXACTLY as it is developed.

It seems to work fine, BUT WHEN I test the 40minute time-limit in many different computers, in some of them the counter starts at 39min40seconds, in others it starts at 38min20seconds... you got the picture...

Question: what is going on?  Why the server-time (FIXED) is not "enough" to garantee that all users will have exactly 40minutes to do their test?

Thanks!
fskilnik.
<script type="text/javascript">
$(function () {

	$('#defaultCountdown').countdown({ format: 'MS', compact: false, 
	                                   expiryUrl: "http://www.mysite.com/closingPage.html", 
      until: new Date(<%=(rsParsingTimes.Fields.Item("YearLimit").Value)%>, 
		   <%=(rsParsingTimes.Fields.Item("MonthLimit").Value)%>-1 , 
     	            <%=(rsParsingTimes.Fields.Item("DayLimit").Value)%>, 
	            <%=(rsParsingTimes.Fields.Item("HourLimit").Value)%>, 
    	            <%=(rsParsingTimes.Fields.Item("MinuteLimit").Value)%>,0,0), 
   timezone: -3});

});
</script>

Open in new window

fskilnikAsked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
the countdown plugin takes a time in the future based on the current time for the user who looks at the page.

So when you are on your server, you want to know when you sent the question
When the user returns 40 minutes later, you do not care on the server, what time it was on the client, as long as it is 40 minutes later.
If you store the timestamp, you also can read the timestamp after the user submits and sends the result to your server.
The user does not care what time it is on your server then and you do not care what time it was on the client.

Yes I know :) I have answered close to 9000 questions at EE, mostly JS/HTML based
0
 
Michel PlungjanIT ExpertCommented:
Can you post the link to this plugin? there are many plugins called countdown

Is it this one http://keith-wood.name/countdown.html ?
0
 
Michel PlungjanIT ExpertCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
fskilnikAuthor Commented:
Thanks for the quick reply, mplungjan!

Yes, that´s the countdown plugin I´m using!

I saw the "serverSync" item/function, but I do not understand php... I´m used to ASP only... could you please "translate" that to asp, for me to try?

By the way... the fact that I calculated time start + 40min = time-limit through SQLserver shouldn´t garantee that the user will have 40min to do the test in any "local" condition?
0
 
Michel PlungjanIT ExpertCommented:
Actually no.

So there is no need for the server date.

I thought you really meant 40 minuted from server date using server date.

Just give it 40 minutes and the script should handle local time just fine

 until: new Date(new Date().getTime()+(40*60*1000))

Open in new window

0
 
Michel PlungjanIT ExpertCommented:
or
var in40Minutes = new Date();
in40Minutes.setMinutes(in40Minutes.getMinutes()+40)
.
..
until: in40Minutes
0
 
fskilnikAuthor Commented:
But using your idea, when the user "refreshes" the page (this is needed to see the next question) or changes his computer clock, the countdown time would be restarted or could be (maliciously) altered, couldn´t it?
0
 
Michel PlungjanIT ExpertCommented:
Yes. If that is your objective, then we do need something more to stop incidental restart, but we can do nothing about malicious restart unless you calculate some kind of hash on the server that contains the start time and then when you receive the answer you compare the end time

So I suggest you create a hidden field with the hashed start time. Give the user 40 minutes local time and when the form submits, you can read the end time from the server when it hits it, and calculate from the hash if it is within a reasonable offset from 40 minutes later
0
 
Michel PlungjanIT ExpertCommented:
0
 
fskilnikAuthor Commented:
Nice... really nice and feasible, because I ALREADY store on my database the exact time the user clicks each answer... but let me ask you something, mplungjian... there is no way to be able to "link" the jquery countdown "strictly" to the server´s time?   I mean, the fact that the program is running in the user´s computer will ALWAYS "disturb" the until countdown parameter?    

I ask you that because from the time, saved on the server, that the user starts the test plus the 40minutes increased in the server, I have the time-limit saved on the server, so couldn´t the countdown simply be "linked" to the server and then be "immune" to local computer configurations?
0
 
fskilnikAuthor Commented:
This EE-post seems to be able to deal with the local x server time conditions...

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23092883.html?sfQueryTermInfo=1+10+30+asp+count+down#a20689674

Do you think I could solve my problem with proper modifications?
0
 
fskilnikAuthor Commented:
The solution to the post I mentioned is YOURS, by the way!!!!
0
 
fskilnikAuthor Commented:
I got the picture, FINALLY LoL !!   I will implement your suggestion and it´s fair to consider the problem solved.

Thanks a LOT, mplungjan. Hope to see you in my next difficulties!!  :)

Best Regards,
fskilnik.
0
 
Michel PlungjanIT ExpertCommented:
You are welcome
PS: I am not Armenian ;)
0
 
fskilnikAuthor Commented:
Thank you!   :)

P.S.: why did you say so? (I have nothing against any religion, race, culture, etc...)
0
 
Michel PlungjanIT ExpertCommented:
I had to remove the i from mplungjian twice :)
0
 
fskilnikAuthor Commented:
Ops... I am really sorry!!!!!!    :)

Well... Feel free to mispell my surname: skilnik  (Jewish) in other opportunities...   ;)
0
 
Michel PlungjanIT ExpertCommented:
:) no problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.