cordoprod Posted February 21, 2008 Share Posted February 21, 2008 Hello! I'm using a flat file db. I want to delete an entry in the db after 3 months from the date I posted it. I just don't know much about the time and date functions in PHP. Any ideas? Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 21, 2008 Share Posted February 21, 2008 explaining something like this is quite complicated.... why cant you use mysql instead? ---- anyway im guessing you know how to find,edit and delete entries from your flat file, so you want to know how to compare a date to check how old it is? first off, save a date_added field with a time(); unix timestamp. check this field like so: if(time() >= ($db_date_added + 2592000)){ // delete entry } this will delete the record after 30 days. -------- also see http://www.php.net/date for more information on the php's date functionality hope this helps, Quote Link to comment Share on other sites More sharing options...
cordoprod Posted February 21, 2008 Author Share Posted February 21, 2008 Thank you very much! Quote Link to comment Share on other sites More sharing options...
cordoprod Posted February 21, 2008 Author Share Posted February 21, 2008 What format of the date() function should I use when I post the entry? Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 21, 2008 Share Posted February 21, 2008 do you mean when you read it? have a look at php.net/date and choose, i usually go for : date("jS F y"); if saving to a db you should ALWAYS use time(); as a unix timestamp, you can use date("jS F y",time()); to format timestamps. hope this helps, Quote Link to comment Share on other sites More sharing options...
cordoprod Posted February 21, 2008 Author Share Posted February 21, 2008 When saving to a DB. So $date should be date("jS F y",time()); ? Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 21, 2008 Share Posted February 21, 2008 when saving to a db $date = time(); when puling from a db use date("jS F y",$date); Quote Link to comment Share on other sites More sharing options...
cordoprod Posted February 21, 2008 Author Share Posted February 21, 2008 Ok thanks 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.