I am trying to learn how to create and test for the expiration of a timestamp. I set up a simple example, trying to test for a timestamp that has expired, but it does not seem to work correctly, and I was wondering if anyone could help me figure out why it wouldn’t echo ‘valid’ and ‘expired’ in the appropriate times?
<?php
echo'
<html>
<head>
</head>
<body>';
//set static current time
$timestamp = 1340037073;
if($timestamp <= strtotime("+10 minutes", $timestamp)){
echo "Valid";
}else{
echo "Expired";
}
echo'
</body>
</html>';
?>
current time is obtained with
time()function, so$timestampshould contain the time obtained from the external source, like database, or whatever, to be checked against current time, to see if it has expired:Hope it works for you 🙂