cgm225 Posted September 9, 2008 Share Posted September 9, 2008 I am writing a script to allow users to comment on blog entries. I have the following mysql comments table: id || comment || for || ip || timestamp I want to do the following: when a comment is added, store a timestamp marking the time of comment creation. Then, if the entry is less than 2 minutes old, allow editing and/or deleting of the comment by that user based on his/her ip address. I also want to prevent new comments from being added more than 1 per five minute period. My question is, what time format should I be storing my timestamp in, and how would you compare it against the timeouts I have outlined above? Thanks again, and any other feedback is appreciated! Quote Link to comment Share on other sites More sharing options...
drisate Posted September 9, 2008 Share Posted September 9, 2008 $current=date("Ymdhis); $time=$current-$timestamp; if ($time>="200")... Quote Link to comment Share on other sites More sharing options...
cgm225 Posted September 9, 2008 Author Share Posted September 9, 2008 Is there anyway to do it based off the mysql CURRENT_TIMESTAMP format? (synonymous with NOW(), see format here) Quote Link to comment Share on other sites More sharing options...
xoligy Posted September 9, 2008 Share Posted September 9, 2008 Im sorry to say but 1 comment per 5minutes seems a little daft even if you mean per user. Say you have 5 people that work in the same office or off the same ip number and they all use your site that means they all have to fight to make a post! Say you have a dormatry of students how can they comment? If you just use the date in mysql and NOW() it do it in the ymdhis format which can be changed when you do a query anyhow. Quote Link to comment Share on other sites More sharing options...
cgm225 Posted September 9, 2008 Author Share Posted September 9, 2008 So how do I go from a... 2003-12-31 00:00:00 ...to a... Ymdhis format? Quote Link to comment Share on other sites More sharing options...
xoligy Posted September 10, 2008 Share Posted September 10, 2008 that is the format Y 2003, m 12, d 31, h12, m30, i10 set your db to date time or date or just time upto you! 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.