I got a voting script that allow people to vote for an item in the database every 24 hour and some more code to check if 24 hours have past or not using 'NOW()' and 'DATE_SUB( NOW(), 'INTERVAL 1 DAY'.
I’m currently trying to add the feature to display how much time is left before the user can vote again using the code below.
$time = explode(" ", $voteCheck[1]);
$year = explode("-", $time[0]);
$date = explode(":", $time[1]);
// Set it all to one long string
$time = $year[0].$year[1].$year[2].$date[0].$date[1].$date[2];
// Current time and date
$cTime = date("YmdHis");
// I get lost here
votcheck is an array from a sql string which just returns the first row as 0 or 1.
1 if the user already voted and 0 if the user can vote again.
The second row returns the date and time the user voted.
I just can’t seem to figure out what to do to get the x amount of hours left before the user can vote again.
My main problem is that the length of the $time string sometime is 13 and sometime 14 characters long.
Ok here it is
Let me know if it works