cloudll Posted March 16, 2012 Share Posted March 16, 2012 Does anybody know how I would turn this into functioning code. if $_SERVER[REQUEST_TIME] is 15 minutes greater than $time_in_database; echo 'time is 15 minutes greater'; Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/259045-comparing-time-in-if-statement/ Share on other sites More sharing options...
dragon_sa Posted March 16, 2012 Share Posted March 16, 2012 if the time in the database is a timestamp you can do this <?php $st = $row['time'] + (15*60); // database time plus 15 mins $t = time(); // current time if ($t >= $st) { // do this } else { // do this } ?> // if you want exactly 15min change >= to == Quote Link to comment https://forums.phpfreaks.com/topic/259045-comparing-time-in-if-statement/#findComment-1327993 Share on other sites More sharing options...
AyKay47 Posted March 16, 2012 Share Posted March 16, 2012 Depending on your logic, you might want to do this in the query itself. Format request_time as yyyy-mm-dd, then use timestampdiff(); Quote Link to comment https://forums.phpfreaks.com/topic/259045-comparing-time-in-if-statement/#findComment-1328028 Share on other sites More sharing options...
cloudll Posted March 16, 2012 Author Share Posted March 16, 2012 thanks your a star Quote Link to comment https://forums.phpfreaks.com/topic/259045-comparing-time-in-if-statement/#findComment-1328224 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.