There is a situation like this, we need a very reliable current time to support, although most of the server time is very accurate, we use time () to obtain the timing is reliable, but there is some uncertainty, and some of the server because it does not open NTP (Network time Protocol) to time synchronization, and because of the hardware environment and other factors, resulting in a variety of time, which in general, but also a few minutes, up to a few hours of the situation is understandable, because in the same site using the same time, but sometimes this is very bad.
On the Internet, there are free timing servers dedicated to UTC time correction, using the NTP protocol, which can refer to the previous link for more knowledge. The time error he provides is around 20ms (not to mention the time that is spent in data transfer, which NTP has already taken into account), so we can get a very credible current time with this timing server.
Let's take a look at how to get very precise UTC time with PHP, because the NTP protocol is a little bit bad, we have a better protocol to use, he is the daytime protocol protocol, through which we can directly get text data, This will be more convenient to handle. We use Time.nist.gov's time service, the code is very simple, with TCP to connect its 13 port on it.
$fp =fsockopen (' time.nist.gov ', $errno, $ERRSTR, n); Echo fread ($fp, 2096);
The data obtained are similar to this:
54979 09-05-28 09:10:50 0 0 206.9 UTC (NIST) *
Each part of this string has meaning, see: http://tf.nist.gov/service/its.htm, now we only care about the middle part and the 206.9 front of the 0, it indicates the health status of the server, also reflects the current time is trustworthy.