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? Link to comment https://forums.phpfreaks.com/topic/92265-entry-disappearing-after-a-specific-time/ 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, Link to comment https://forums.phpfreaks.com/topic/92265-entry-disappearing-after-a-specific-time/#findComment-472678 Share on other sites More sharing options...
cordoprod Posted February 21, 2008 Author Share Posted February 21, 2008 Thank you very much! Link to comment https://forums.phpfreaks.com/topic/92265-entry-disappearing-after-a-specific-time/#findComment-472679 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? Link to comment https://forums.phpfreaks.com/topic/92265-entry-disappearing-after-a-specific-time/#findComment-472727 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, Link to comment https://forums.phpfreaks.com/topic/92265-entry-disappearing-after-a-specific-time/#findComment-472747 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()); ? Link to comment https://forums.phpfreaks.com/topic/92265-entry-disappearing-after-a-specific-time/#findComment-472752 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); Link to comment https://forums.phpfreaks.com/topic/92265-entry-disappearing-after-a-specific-time/#findComment-472756 Share on other sites More sharing options...
cordoprod Posted February 21, 2008 Author Share Posted February 21, 2008 Ok thanks Link to comment https://forums.phpfreaks.com/topic/92265-entry-disappearing-after-a-specific-time/#findComment-472759 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.