|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
PHP: Determining if a Timestamp Has ExpiredLet's say you're caching a file every 24 hours. You need to know when 24 hours has passed since the last cache. Here's the code: $LastCacheTime = file_get_contents('LastCacheTime.txt');
if (time() >= strtotime("+24 hours", $LastCacheTime)) {
file_put_contents('LastCacheTime.txt', time());
}
else {
}
In this case, the file LastCacheTime.txt contains the unix timestamp of the last time the interval expired.
|
|
|
|
|