Home > front end >  JS, how to get the current network time is not a request.
JS, how to get the current network time is not a request.

Time:10-15

Want to have a demand for JS for network time recently, but because the use frequency is a little high, so can not initiate the request, will be able to get the current network time,

CodePudding user response:

Network time is you say?

CodePudding user response:

Does not send requests, we won't be able to get??

CodePudding user response:

Or send request, and to obtain a "network" of time, you think again,

CodePudding user response:

You can get a page is loaded, then front setInterval, this will only transfer request at a time

CodePudding user response:

reference 1st floor a76326791212 response:
network time is you say?

Means, standard Beijing time is not on your own computer,

CodePudding user response:

reference 4 floor zc_1994 response:
you can get a page is loaded, then front setInterval, this will only adjust a request

It is also a method, but not in a page, many pages in use, and high frequency, each request interface must take!

CodePudding user response:

reference X - I - n reply: 3/f
or send request again and again to get the "network" of time, you think again,

Let you see my leadership, is a blast!

CodePudding user response:

You can start to send a request to obtain a network time, with the client timestamp and network time timestamp is presupposed, and get a time value,

With the client time after time stamp and the time difference value, is the network time,


CodePudding user response:

reference 5 floor Chappell_ycp reply:
Quote: refer to 1st floor a76326791212 response:
network time is you say?

Means, standard Beijing time is not on your own computer,

If the new Date () is a standard Beijing time. ToLocaleString (' en - US, {timeZone: 'Asia/Shanghai}),

PS: why didn't you back end timestamp processing?

CodePudding user response:

reference sky waves on the eighth floor response:
you can start to send a request to obtain a network time, with the client timestamp and network time timestamp is presupposed, and get a time value,

As long as with the client after the timestamp and the time value of time, is the network time,

This method is very good, but I use words, leadership will say no, say I opportunistic, so what also don't say to him one by one to request, the page will slowly, slowly can't,

CodePudding user response:

references 9 f a76326791212 response:
Quote: refer to the fifth floor Chappell_ycp reply:
Quote: refer to 1st floor a76326791212 response:
network time is you say?

Means, standard Beijing time is not on your own computer,

If the new Date () is a standard Beijing time. ToLocaleString (' en - US, {timeZone: 'Asia/Shanghai}),

PS: why didn't you back end timestamp processing?

Or no, I changed the computer time he still get computer time, and just changed the time zone, time or computer time,