For example, to do a time-limited shopping function, it is necessary to do the countdown, to have a real-timer countdown.
Requires the display of a real-time countdown of hours minutes seconds, and the user-side modification date time does not affect the normal display of the countdown (that is, the server time).
In fact, this and a lot of examinations and other systems of time limit function the same requirements.
It is not always possible to use Ajax to get server time every second, so the real-time countdown must be implemented with JavaScript. This is simple, a bunch of examples online.
The problem now is to address the effect of the user-side modification date time on our display.
The solution is to calculate the time between the client and the server, so the problem is solved.
This only needs to run PHP once, and the time of the real-time countdown is synchronized with the server's time.
The theory is synchronous, but the actual test will have a 1 second error. (The specific reason is connected with the speed, the faster the speed, the smaller the error), but this will not affect our requirements above.
Program Demo
XX: xx: XX
Note: The seconds kill time from morning to evening 10 o'clock.
Code is as follows:
XX:xx: xx
http://www.bkjia.com/PHPjc/752493.html www.bkjia.com true http://www.bkjia.com/PHPjc/752493.html techarticle For example, to do a time-limited shopping function, it is necessary to do the countdown, to have a real-timer countdown. Request to have the hour minute seconds of the real-time countdown display, the user-side modification date time does not ...