I am trying to see if one date is within a 24 hour period. If so, do not allow something, if it is outside of that 24 hour period, do something. $now = date("Y-m-d : H:i:s", time()); $twenty4hoursPrevious = date('Y-m-d : H:i:s', strtotime('-1 day')); i believe this is right so far but when i get to comparing i get the wrong result. if($twenty4hoursPrevious < $now) { //do nothing } else { //do something } any ideas? Thanks!
Figured it out. I wasnt converting another value to string. I also reworked the problem. $fbuserLastVoteTime = "2011-01-10 12:12:12"; //$row['timestamp']; $now = strtotime(date("Y-m-d H:i:s")); $nowMinus24hours = strtotime('-24 hours', $now); echo "Last Vote Time: " . strtotime($fbuserLastVoteTime) . "<br>"; echo "Now: " . strtotime($now) . "<br>"; echo "24 hours previous: " . $nowMinus24hours . "<br>"; if($fbuserLastVoteTime < $nowMinus24hours) { echo "good to go"; } else { echo "cant vote"; } woop
I am little dissoriented, so this script checks if user voted in last 24 hours and if yes, your system won't allow them to vote again, however if they didn't voted in last 24 hours they can vote. Am I right? I know you don't need support anymore, but looks like good script so I'm interested