我正在使用current_timestamp.“从现在开始的某一天”,我需要找出什么函数?


I'm working with a current_timestamp. What function do I need to find out "one day from now"

使用MySQL,我有一个当前时间戳,看起来像这样:

2011-11-01 10:34:24

是否有一个PHP函数,我可以使用"检查"这次?我想知道,从"现在"算起,这个时间是否超过了一天。

编辑:解决方案(适用于我的使用情况)

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"; 
} 

对于MySql,您可以尝试:

SELECT * FROM your_table
WHERE date >= DATE_SUB(NOW(), INTERVAL 1 DAY)
$some_date = strtotime('2011-11-01 10:34:24');
$now = time();
$seconds_diff = $now - $some_date;
$days = $seconds_diff / 86400;
echo $days;