Jump to content

Timestamp... what format to use, how to check against...


cgm225

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.