Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下代码
echo $lastmoment."<br/>"; echo time(); echo "<br/>"; echo strtotime($lastmoment);
输出:
2009-12-15 17:40:53 1260876829 1260898853
怎么了?$lastment 是 MySQL 中过去的时间戳,为什么 strtotime($lastmoment) 比 time() 大?
如果您的 MySQL 服务器是不同的机器,或者 $lastmoment 中的时间戳是从不同的机器设置的,您可能会看到时钟漂移。检查各种机器上的系统时钟,看看它们是否一致。
因为 time() 函数可能在 $lastmoment 之前几毫秒执行。
编辑:将评论添加到我的想法中,我可能认为 strtotime() 的转换可能失败了。或者数据库中的日期值包含一个值,例如 date() 没有的天数。请确保您比较了相同格式的 2 个日期值。