Using MySQL, i have a current timestamp that looks like this:
2011-11-01 10:34:24
Is there a PHP function that I could use to “check against” this time? I want to know if this time is more than a day old from “now”.
Edit: Solution (that works for my usecase)
date_default_timezone_set('UTC');
// date voted
$date_voted = '2011-09-01 10:34:24';
// +24
$future_time = ( strtotime($date_voted) ) + 86400;
// current time
$curr_time = time();
if ( $curr_time < $future_time ) {
echo "You can't vote just yet!\n\n";
} else if ( $curr_time >= $future_time ) {
echo "Vote counted!\n\n";
}
1 Answer