Reputation: 49817
i need to check if a timestamp is expired datetime, by comparing that to the current timestamp
So i have :
$current_timestamp = time();
$db_timestamp = 134500809
My dubt is, is it correct in all cases to do (is it always TRUE):
if($current_timestamp > $db_timestamp){
// $db_timestamp is expired for sure
}
or should this be FALSE in some cases?
Upvotes: 0
Views: 2521
Reputation: 4399
It will be false
if the timestamp from the database is in the future, thus it will work properly.
Try inserting a row in your database and set the timestamp to time() + 3600
, then you'll see that your if statement is correctly evaluated and returning false
until one hour has passed.
Upvotes: 1