onlyican Posted March 19, 2007 Share Posted March 19, 2007 Hey people I am storing Date Time in the mySQL Table in the following format Y-m-d H:i:s (This is 2007-19-03 10:56:01) I want to check if that Date Time is within 10 minutes of NOW How would I do this? Its ok if the date time is as is above. But if now is 2007-19-03 00:03:04 (3 Minutes past midnight) That means having to then check Date -1 Any pre-built functions for this? Link to comment https://forums.phpfreaks.com/topic/43334-date-minus-10-mins/ Share on other sites More sharing options...
Vikas Jayna Posted March 19, 2007 Share Posted March 19, 2007 Use the following expression in the where clause of the query:- where DATE1 >= DATE_SUB(NOW(), interval 10 MINUTE) Link to comment https://forums.phpfreaks.com/topic/43334-date-minus-10-mins/#findComment-210413 Share on other sites More sharing options...
onlyican Posted March 19, 2007 Author Share Posted March 19, 2007 but I need it in PHP, as I need to seperate the ones that are within 10 minutes and ones that are outside of the 10 minutes. Link to comment https://forums.phpfreaks.com/topic/43334-date-minus-10-mins/#findComment-210416 Share on other sites More sharing options...
mjlogan Posted March 19, 2007 Share Posted March 19, 2007 Use the string to time function and then, minus 10*60 from the result and you will have a time stamp of ten minutes earlier than your original time. You can do what you want with it then. Link to comment https://forums.phpfreaks.com/topic/43334-date-minus-10-mins/#findComment-210429 Share on other sites More sharing options...
onlyican Posted March 19, 2007 Author Share Posted March 19, 2007 ok cheers, got it now Link to comment https://forums.phpfreaks.com/topic/43334-date-minus-10-mins/#findComment-210443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.