javascript - Retrieving exact clients time in C# -


To date I dateTime.Now; I am using the function, okay, in the later stage, I used javascript to keep the client's date and time in time zone. But when I change the date and time of my system and try javascript. It shows the converted time of my computer how should I fix the customer's current date and time value. How to get it.

Please do not answer more than C #; On the client, when the client sends a request with Javascript, get the new date (). (Tomas) (java).

) and send it to the server. ToJSON (GMT + 0000) gives the current customer datetime in Timezone (Greenwich):

  var dtStr = new date (). ToJSON ();   

on the server, C #:

  date time dtServer = DateTime.Now; DateTime dtClient = DateTime.Pres (Request.JQueryString ["dtStr"]); // or request.form double request timedelata = 10f; // starts the maximum time request in seconds between the client, // and this code lines are executed. Double second delta = 2f; DateTime max = dtClient.AddSeconds (requestTimeDelta + secondsDelta); Date time minimum = dtClient.AddSeconds (-secondsDelta); If (max> gt = dtServer & amp; amp; minute; & lt; = dtServer) {// time is correct} other {// time is wrong}   

above Code is required, at that time the customer and server are synchronized with global clocks (for example, Internet TimeSource Server). To avoid this problem, you can distinguish between the difference between client and server clocks (for example, in the session, for example) initial (on first request), and this "difference" max And minutes variable This behavior is for coding only, and is not shown in the above code.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -