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.
我需要通过将其与当前时间戳进行比较来检查时间戳是否已过期
所以我有 :
$current_timestamp = time(); $db_timestamp = 134500809
我的问题是,在所有情况下都正确吗(总是正确的):
if($current_timestamp > $db_timestamp){ // $db_timestamp is expired for sure }
或者在某些情况下这应该是 FALSE 吗?
如果数据库中的时间戳在将来,它将false是,因此它将正常工作。
false
尝试在您的数据库中插入一行并将时间戳设置为time() + 3600,然后您将看到您的 if 语句被正确评估并返回false,直到一小时过去。
time() + 3600