monkeypaw201 Posted July 30, 2008 Share Posted July 30, 2008 I have a database with a time column where i insert the time using the date("now") function.... I need to be able to add 24 hours... Using that new variable i need to find out if that date/time has already passed or not. So.. 1. How do I add 24 hours? 2. Will $added_time < $date("now) work for an if..else? Link to comment https://forums.phpfreaks.com/topic/117271-solved-adding-time/ Share on other sites More sharing options...
Jabop Posted July 30, 2008 Share Posted July 30, 2008 I believe it's something like DATE_ADD(CURDATE(), INTERVAL 1 DAY) This is MySQL, not php () Link to comment https://forums.phpfreaks.com/topic/117271-solved-adding-time/#findComment-603244 Share on other sites More sharing options...
.josh Posted July 30, 2008 Share Posted July 30, 2008 Dunno how you plan on retrieving this date in question, but assuming you have an id associated to it in the row... // important thing here is to get the date, so do whatever you got to do to get it $sql = "select datecolumn from table where id = '$id'"; $result = mysql_query($sql); if ($result) { $date = mysql_result($result, 0, 0); $date = strtotime($date) + 86400; if ($date > time()) { // do something } } Link to comment https://forums.phpfreaks.com/topic/117271-solved-adding-time/#findComment-603247 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.