The following code
ech开发者_开发问答o $lastmoment."<br/>";
echo time();
echo "<br/>";
echo strtotime($lastmoment);
outputs:
2009-12-15 17:40:53 1260876829 1260898853
What's wrong? $lastment is a past time stamp in MySQL, why is strtotime($lastmoment) bigger than time()?
If your MySQL server is a different machine, or if the timestamp in $lastmoment was set from a different machine, you could be seeing clock drift. Check the system clocks on the various machines, and see if they agree.
Because the time() function was may be executed some milliseconds before the $lastmoment.
EDIT: Adding the comment to my thoughts, it might me that, the convert of strtotime() might have failed. Or the date value from the database contains a value e.g. days which the date() does not have. Be sure, that you compare 2 datevalues of the same format.
精彩评论