PHP: Determining if a Timestamp Has Expired

Let'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:

PHP Code
$LastCacheTime = file_get_contents('LastCacheTime.txt');
if (time() >= strtotime("+24 hours", $LastCacheTime)) {
   // Save the new cache time to disk.
   file_put_contents('LastCacheTime.txt', time());
   // Interval has expired.
}
else {
   // Interval has not expired.
} 


In this case, the file LastCacheTime.txt contains the unix timestamp of the last time the interval expired.


The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)