简体   繁体   中英

Compare time in php with current time

I am trying to compare time got from url:

$expireTime = $_GET['st']; //the parameter is made like: time() + 3600;

if(time() <= $expireTime){
    print_r('valid time');
} else {
    throw new Exception("Time expired");
}

but it is always time expired.

Please use following.

$expireTime = $_GET['st']; //the parameter is made like: time() + 3600;
$expiretime = strtotime($expireTime);
if(time() <= $expiretime){
print_r('valid time');
} 
else {
throw new Exception("Time expired");
}

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