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? Link to comment https://forums.phpfreaks.com/topic/160326-solved-add-minutes-or-hours-to-time/ 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. Link to comment https://forums.phpfreaks.com/topic/160326-solved-add-minutes-or-hours-to-time/#findComment-846058 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. Link to comment https://forums.phpfreaks.com/topic/160326-solved-add-minutes-or-hours-to-time/#findComment-846061 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 Link to comment https://forums.phpfreaks.com/topic/160326-solved-add-minutes-or-hours-to-time/#findComment-846066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.