RE: [PHP-DB] Difference in time
| From: | John W. Holmes | Date: | Wed, 02 Oct 2002 23:01:35 +0000 |
| Subject: | RE: [PHP-DB] Difference in time | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22178@lists.php.net to get a copy of this message | ||
> I am fighting a time issue(don't we all). I have a online poll set up.
I
> need a way to stop a person from
> submitting more than once an hour. As of now I have the time ..
mktime(
> ) .. being stored in a database along
> with the users IP.
>
> I want to be able to say if 1 hour has passed from the time .. mktime(
)
> .. that is stored in the db they can vote once again. This also has to
> account that if someone goes to the poll tomorrow at the same time
(same
> hour) the script knows it's a different hour and different day.
>
> Scenario: I submit to the poll at 12:00 PM, one hour from now will be
> 1:00 PM and I can submit again. Now lets
> say it's 12:00 PM the next day. The database stored time will say
12:00
> PM of the day before, It will not let me submit because it thinks that
> it has to be at least 1:00 PM before I can submit again. Which is
wrong.
>
> I was trying to use the mktime( ) function but it keeps giving me
these
> results.(( 1033578795 )) The last few
> numbers change but the first few (that as suppose to be the hour) does
> not change?
> mktime(int hour, int minute, int second, int month, int day, int
year).
> How can I use this mktime( ) function to do what I need it to? Am I
> going in the wrong direction?
SELECT 1 FROM table WHERE FROM_UNIXTIME(last_post) < (NOW() - INTERVAL 1
HOUR) AND User_ID = XXX
If a row is returned, then the user is clear to vote, it's been over an
hour.
---John Holmes...