time() 根据服务器返回不同的时间戳 [英] time() returns different timestamps based on server
问题描述
我现在搜索了好几个小时,以前好像没有人遇到过这个问题.
I searched now for many hours, it seem's like nobody got that problem before.
我在两台服务器上运行了一个脚本,该脚本将当前时间戳写入数据库.两者都具有相同的操作系统、软件……以及相同的时区.
I run a script, which writes the current timestamp into a database, on two servers. Both have the same os, software, ... and the same timezone.
现在我发现,某些时间戳和当前 time() 之间的差异是一个负数(是的,计算是正确的:time() - $older_timestamp
)
Now I found out, that the diff between some timestamps and the current time() is a negative number (yes, the calculation is correct: time() - $older_timestamp
)
我在两台服务器上都转储了 time(),结果是:相差一小时.看看:
I dumped time() on both servers, the result: it differs by exactly one hour. Check it out:
由于 time() 应该始终基于 UTC,我无法解释,这是如何发生的.
Since time() should be always UTC-based, I can not explain, how this happens.
有人知道吗?
来自亚琛的问候
推荐答案
显然服务器一和服务器二设置为不同的时间.检查BIOS 和服务器的操作系统时间.
Apparently server one and server two are set to different times. Check BIOS and your servers' OS time.
这篇关于time() 根据服务器返回不同的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!