Ninjakreborn Posted September 11, 2006 Share Posted September 11, 2006 I have something that I find myself doing quite a bit, but I end up doing it the same way everytime. I have a number, for instance 30. I need it to go down daily, like if 3 days go by, I need it to be 27, and so forth until it hit's 0, then I can do something with it. Like a timeperiod of how long something can be active. The thing is I always record the date like 09-11-06 or something in the database, this is the date that the item, or whatever was entered into the database, then I have the current date. I use something, like I decide when is the best imte, like right when they log in, or right when a specific page is open. Then I check the date, turn it into a timestamp, record todays date, turn it into a timestamp, compare them, do some calculations, to make the date update, and that's it. Then I go back, and above that, do a check for the 0 or less value, so it doesn't run unnecessary calculations, and instead either deletes the item, or moves it into another table for old items, or something, this would be whatever, a use with a timelimit on a paid account, or the lifetime of the post for a classified system. does anyone know of a better way to do this, or a place I can put the information to run the script, somewhere that won't kill the server. Because if I check all the entries in all the database, and update them all everytime someone logs in, or visits the site, then it might kill the server if a lot of people hit the site at once. I don't really want that happened, and hoenstly, that many database calls at that many times, can calls db rewrites, and a lot of other things, and make the information in accurate. Or it could end up doing it 2-3 times before it updates the number, and make the number over-update. I am thinking of checking an individual users posts everything he/she logs into the site. Then I also have the problem of people who create accounts, put some posts down then never come back to the site, they never get deleted. Should I check each post individually. Like if someone is browsing posts, go ahead and check then, or does anyone have another way of doing this, any advice, opinions are welcome, I have to do something to return a number of day's left, that's the whole point. Quote Link to comment https://forums.phpfreaks.com/topic/20399-date-calculations/ Share on other sites More sharing options...
ober Posted September 11, 2006 Share Posted September 11, 2006 Please.... for our own sanity... if you're going to ramble for that long, break it up with a few presses of the "Enter" key from time to time. No one wants to read a giant hunk of text like that. Quote Link to comment https://forums.phpfreaks.com/topic/20399-date-calculations/#findComment-89861 Share on other sites More sharing options...
hostfreak Posted September 11, 2006 Share Posted September 11, 2006 Got half away through that before I started to get a headache. I'll come back and read the other half after I recover. Hopefully then I will be able to offer some advice. Quote Link to comment https://forums.phpfreaks.com/topic/20399-date-calculations/#findComment-89862 Share on other sites More sharing options...
AndyB Posted September 11, 2006 Share Posted September 11, 2006 [quote]I always record the date like 09-11-06[/quote]Is that day month year, or month day year, or year month day, etc. I bet you'll find doing anything with dates that it's simpler to use yyyy-mm-dd [the ISO standard date format] in your database. You can, of course, re-present dates drawn from the database in any format you want.And Ober's right. Split it up into coherent thoughts in paragraphs. Make this stuff easier for us to read!!!! Quote Link to comment https://forums.phpfreaks.com/topic/20399-date-calculations/#findComment-89871 Share on other sites More sharing options...
Ninjakreborn Posted September 11, 2006 Author Share Posted September 11, 2006 It's set up like month-date-yearI have it formatted in the databas,e I can save it however, if it's better then I will start saving it in that format.The thing I was wondering was, is there another way to do calculations, or is there a good place to put the program to keep it from overloading the server, if a lot of people get it to do the same thing everytime. Quote Link to comment https://forums.phpfreaks.com/topic/20399-date-calculations/#findComment-89905 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.