Hello I have a vote system.
Once a person votes, I have column named "nextVote".
That column will hold the date when the user can vote again. By that column, I will be able to echo how many hours/minutes he needs to wait before voting.
That's my try:
public final function setNextVote($ip)
{
$this->insert = $this->pdo->prepare("UPDATE auths SET nextVote = NOW() + INTERVAL 12 HOUR WHERE voter_ip = :ip");
$this->insert->execute(array(":ip" => $ip));
}
And that what it stores:
2013-05-14 05:56:24
Why?..
What I am trying to do is: Current time + 12 hours.
If today is 2013, 05, 14 and 12:00.
In 12 hours it would be
2013, 05, 14, 24:00 Why doesn't it do that?
public function getTimeLeft($ip)
{
$this->get = $this->pdo->prepare
("
SELECT TIMESTAMPDIFF(MINUTE, `nextVote`, NOW())
FROM auths
WHERE `voter_ip` = :ip
");
$echo = $this->get->execute(array(":ip" => $ip));
return $echo;
}