Reputation: 317
I am working on online quiz so for main quiz questions i want to add on condition that checks users system date time and server date time if it match then quiz should be start, can anyone know how to do this. please response if anyone knows about it
Upvotes: 1
Views: 116
Reputation: 483
Actually, as you are doing a web application, so the DateTime.Now in your back-end code is already the DateTime of server. So the problem now is how to get the datetime of client pc.
What I can come out with at the moment is :
Create hidden filed in your page
Assume you are using ASP.NET, you can just give your input control a runat="server"
attribute like any other server side control.
Before you submit the quiz, update the filed using js
The server can then read it when the form posts back.
Compare the time with your server time to do any logic you want
Upvotes: 1
Reputation: 31
There you go to catch the client date. Javascript Date Localization
You can use this and pull this information via ajax to your server and validate it.
Upvotes: 1