phpretard Posted May 31, 2009 Share Posted May 31, 2009 I am trying to add minutes or hours to $current. This time should expire after $var hours. So I need this to compare now() to $expired $current="2009-05-30 09:32:23"; $exired="2009-05-30 09:32:23" + $hours; if ($expired >= now()){ times up }else{ your still good } any suggestion? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 It'll be hard to do it with PHP. Best just use MySQL to do it. Quote Link to comment Share on other sites More sharing options...
phpretard Posted May 31, 2009 Author Share Posted May 31, 2009 This did it. I insert it in mysql as the expired time and compair against it. connect(); $get_time_limit=mysql_query("select time1 from preferences"); $timelimit=mysql_fetch_assoc($get_time_limit); $exp=time() + (1 * $timelimit['time1'] * 60 * 60); $expired=date('Y-m-d H:i:s', $exp); mysql_free_result($get_time_limit); Thank you for looking at it. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 I think this should work - SELECT FROM_UNIXTIME(time1 + 3600, '%Y-%m-%d %H:%i:%s') AS time FROM preferences Quote Link to comment 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.