loquela Posted March 7, 2009 Share Posted March 7, 2009 Hi there, I have a simple commenting feature I have a column in my user table: last_comment (datetime). I want to check this value and prevent commenting if it is less than 10 minutes old. So I want to create the variable: $lastcomment = last_comment + 10 minutes. Any help greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/148348-datetime-adding-and-subtracting-time/ Share on other sites More sharing options...
kickstart Posted March 7, 2009 Share Posted March 7, 2009 Hi Probably easiest to just keep it within MySQL, and the function to add time in MySQL is DATE_ADD, so you would check against DATE_ADD(NOW(), INTERVAL -10 MINUTE) All the best Keith Link to comment https://forums.phpfreaks.com/topic/148348-datetime-adding-and-subtracting-time/#findComment-778824 Share on other sites More sharing options...
loquela Posted March 7, 2009 Author Share Posted March 7, 2009 Brilliant. Thanks Link to comment https://forums.phpfreaks.com/topic/148348-datetime-adding-and-subtracting-time/#findComment-778840 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.