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 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 == 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(); 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 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
Archived
This topic is now archived and is closed to further replies.