Vivid Lust Posted December 1, 2009 Share Posted December 1, 2009 I was wondering how I could check if a timestamp from time(), can be checked to see if it was made more thank 2 hours ago? so $timeInDatabase = 1259691739; $timeTwoHoursAgo = foo; if( $timeInDatabase <= $timeTwoHoursAgo ){ //do this } any help on filling this in? thanks lots Quote Link to comment https://forums.phpfreaks.com/topic/183619-check-if-a-stored-time-is-more-than-2-hours-ago/ Share on other sites More sharing options...
salathe Posted December 1, 2009 Share Posted December 1, 2009 You could use strtotime to generate the timestamp 2 hours ago. Quote Link to comment https://forums.phpfreaks.com/topic/183619-check-if-a-stored-time-is-more-than-2-hours-ago/#findComment-969154 Share on other sites More sharing options...
premiso Posted December 1, 2009 Share Posted December 1, 2009 An alternative to strtotime $timeTwoHoursAgo = time()-60*60*2; // minus 60 seconds times 60 minutes times 2 = 2 hours ago) Either or works, the strotime is probably easier to read. Quote Link to comment https://forums.phpfreaks.com/topic/183619-check-if-a-stored-time-is-more-than-2-hours-ago/#findComment-969171 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.