I am building a caching system to store Twitter API tweets as to avoid violating the hourly call limit.
I am storing the tweets in a database with a timestamp and then checking in PHP to see if the timestamp is an hour old, if so then I call the API again. At the moment I can’t seem to get it working. Here is what I curently have (which I admit is most probably wrong!)
if($results->tweet_date <= strtotime('-1 hours')) {
//do api call
} else {
//call tweets from database
}
This doesn’t seem to be working though. Can anyone point me in the right direction?
Thanks!
What about using the timestamp minus 3600?
EDIT: If you want to use
strtotime, you can usestrtotime('-1 hour')to calculate the time (mind the hour instead of hours).