affordit Posted January 24, 2008 Share Posted January 24, 2008 What I would like to do is add an expire date that is 30 days out based on the Time_submitted value but I have no clue where to start can anyone help? <?php include("k_falls_dbinfo2.inc.php"); mysql_connect(mysql,$username,$password); mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO test (name, time_submitted) VALUES ('$name', now())"; mysql_query($query); mysql_free_result( $result ); mysql_close(); echo "All Done."; ?> Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/ Share on other sites More sharing options...
affordit Posted January 24, 2008 Author Share Posted January 24, 2008 Is there a way to add days to the timestamp and then post the result to my table? Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448316 Share on other sites More sharing options...
resago Posted January 24, 2008 Share Posted January 24, 2008 strtotime() Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448322 Share on other sites More sharing options...
affordit Posted January 24, 2008 Author Share Posted January 24, 2008 I tried this line and it returns 1201820620 is there a way to add days to the now() function $expire=(strtotime("+1 week"); Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448354 Share on other sites More sharing options...
teng84 Posted January 24, 2008 Share Posted January 24, 2008 ??? now() of mysql will do it flawlessly.. all you need to do is insert the current date then query it something like sample your field for the date is my_date all you need is a query that says select * from table where DATEDIFF('now()','my_date') <=30; // returns all dates that is less than 30 days does that help? Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448397 Share on other sites More sharing options...
affordit Posted January 24, 2008 Author Share Posted January 24, 2008 Yes that does help alot thanks what I am tring to do is get a expire date based on the start date to insert at the same time, then I can send email based on the expire date. Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448401 Share on other sites More sharing options...
cooldude832 Posted January 24, 2008 Share Posted January 24, 2008 don't make it expire just simply don't display it after 30 days. Then make your garbage collect cron job clean up old ads every week or so often. Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448405 Share on other sites More sharing options...
teng84 Posted January 24, 2008 Share Posted January 24, 2008 I used now as expiration date you can also put what ever youwant select (DATEDIFF('now()','my_date') -30) as days expire from table where DATEDIFF('now()','my_date') >30; //returns the number of days of expiration eg. if 31 1 day expired... select DATEDIFF('now()','my_date') as days expire from table where DATEDIFF('now()','my_date') >30; // returns the total days of exiration eg 30 31, 32 etcc maybe this? Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448409 Share on other sites More sharing options...
affordit Posted January 24, 2008 Author Share Posted January 24, 2008 don't I need to have an expire date to compare so that I can send emails to them that will include a renew option Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448410 Share on other sites More sharing options...
teng84 Posted January 25, 2008 Share Posted January 25, 2008 how do you want your expiration date to be compared where will it come from? Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448415 Share on other sites More sharing options...
affordit Posted January 25, 2008 Author Share Posted January 25, 2008 I have a number of different subscription and I need to be able to generate a expire date based on when they signed up. I hope that made sense Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448422 Share on other sites More sharing options...
teng84 Posted January 25, 2008 Share Posted January 25, 2008 you can add fields or tables.. that will have expiration range and maybe expiration id so to set it up you will have something like this exId Range 1 10 2 20 3 30 //ect... select DATEDIFF('now()','my_date')as days expire from table where DATEDIFF('now()','my_date') >Range and exId = 'youridhere'; does that makes sense? Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448442 Share on other sites More sharing options...
affordit Posted January 25, 2008 Author Share Posted January 25, 2008 So I set up new fields for id and range and the range would be the amount of days till it expires? Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448460 Share on other sites More sharing options...
teng84 Posted January 25, 2008 Share Posted January 25, 2008 yes.. id would be the type of user because the way i understand you diff user has diff expiration so user type 1 expire 20 days and user 2 expire in 10 days etc... Quote Link to comment https://forums.phpfreaks.com/topic/87649-solved-is-there-a-way-to-do-this-or-am-i-asking-too-much/#findComment-448462 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.