coupe-r Posted April 19, 2010 Share Posted April 19, 2010 Hey Guys, I have a strtotime() variable inserted into the DB, which serves as an expiration date. I want to alert the user 7 days before expiration. $next_week = strtotime("+1 week"); SELECT COUNT(lease_end_int) FROM tenants WHERE lease_end_int < ' ".$next_week." ' lease_end_int is stored as a INTEGER(10) in the DB.. Apparently this is not working. Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/199014-comparing-values-help/ Share on other sites More sharing options...
TeddyKiller Posted April 19, 2010 Share Posted April 19, 2010 If the expiration is in the db then $row['expiration'] is the expiration in this case. $expiration = $row['expiration']; $expiration -= 7 / 24 / 60 / 60; if(time() > $expiration) { if(time() < $row['expiration']) { echo 'You have not reached the expiration date yet!'; } } Quote Link to comment https://forums.phpfreaks.com/topic/199014-comparing-values-help/#findComment-1044618 Share on other sites More sharing options...
JustLikeIcarus Posted April 19, 2010 Share Posted April 19, 2010 Why not just store the value as an actual mysql date instead of a unix timestamp? Quote Link to comment https://forums.phpfreaks.com/topic/199014-comparing-values-help/#findComment-1044623 Share on other sites More sharing options...
coupe-r Posted April 21, 2010 Author Share Posted April 21, 2010 OK, im now storing the dates as yyyy-mm-dd. Now, how can I set a variable that is always 7 days ahead of the current date? Quote Link to comment https://forums.phpfreaks.com/topic/199014-comparing-values-help/#findComment-1045509 Share on other sites More sharing options...
JustLikeIcarus Posted April 21, 2010 Share Posted April 21, 2010 Use mysql's function DATE_ADD(CURDATE(),INTERVAL 7 DAYS) Quote Link to comment https://forums.phpfreaks.com/topic/199014-comparing-values-help/#findComment-1045511 Share on other sites More sharing options...
coupe-r Posted April 21, 2010 Author Share Posted April 21, 2010 I just found $next_week = date('Y-m-d', strtotime("+7 days")); Does the same thing. Thanks for replying. Quote Link to comment https://forums.phpfreaks.com/topic/199014-comparing-values-help/#findComment-1045513 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.