0
我想檢查一下我存儲在數據庫中的哈希是否已過期,即大於30分鐘。PHP - 檢查哈希是否已過期
這是我的支票
$db_timestamp = strtotime($hash->created_at);
$cur_timestamp = strtotime(date('Y-m-d H:i:s'));
if (($cur_timestamp - $db_timestamp) > ???) {
// hash has expired
}
由於unix時間戳在secon ds,那麼比較的值是30 * 60 = 1800 –
而你不需要'$ cur_timestamp = strtotime(date('Ymd H:i:s'));'',只需使用'$ cur_timestamp = time() ' –