PHP - 检查某个时间日期是否已过


PHP - Checking if a timedate has past

$from = time();
$to = strtotime($row['clock']);
if($to<$from){
    echo("Time has past.");
}

我只是想用一个简单的 IF 语句检查时间是否已经过去了。

目前,if 语句始终为真,无论日期时间如何。

$row['时钟'] = 2013-10-31 00:04:00

这在这里工作正常。确保$row['clock']包含您认为它的作用。

$from = time();
$to = strtotime('2013-11-01 00:00:00');
if($to<$from){
    echo("Time has past.");
}

在我的机器上没有任何回显,而:

$from = time();
$to = strtotime('2013-10-01 00:00:00');
if($to<$from){
    echo("Time has past.");
}

回应"时间已经过去了。

除此之外,请检查服务器的时间设置是否正确。