07-16-2010, 07:46 PM
|
#2 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Quote:
Originally Posted by Killswitch
I know, this should be an incredibly easy task but for some reason I just cannot get it to work properly.
I have a comment form that needs to check a users last post time to the current, and see if at least 30 seconds have passed before allowing them to post again.
The users last post is stored as datetime (Y d m H i s), and the current time is generated as time().
I am converting the users datetime with strtotime, and checked that it worked by using a timestamp converter.
How would I gather a 30 second time difference between the two? I've been trying to add 30 to the users time, which is obviously wrong because when I print that back out, I get a timestamp for something like January of 2051 :(
If anyone can help, I would much appreciate it!
|
First off, always store your times as timestamps. It is considerably easier to work with the numbers and convert to a string when you need it than vice versa.
You would get a thirty second time difference when laterStamp-firstStamp>=30.
|
|
|
|