简体   繁体   中英

PHP - Checking if a timedate has past

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

I am just trying to check if the time has past with a simple IF statement.

Currently the if statement is always true, no matter the datetime.

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

This works fine here. Make sure $row['clock'] contains what you think it does.

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

echos nothing on my machine, while:

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

echos "Time has past.".

Barring that, check that your server's time is correctly set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM