PHP 计算 24 小时时差


PHP Calculate 24 Hours time difference

我想检查自 PHP 函数上次查询以来是否超过 24 小时。首先,我必须从数据库中选择上次查询日期和时间,然后我需要用当前时间计算它,并检查自上次查询以来是否超过 24 小时。我该如何做到这一点?需要菜鸟答案!

如果您有日期时间行,您可以像这样检查返回的行数:

$result = mysqli_query($link,"SELECT * FROM table WHERE datetime < NOW() - INTERVAL 1 DAY");
if(mysqli_num_rows($link, $result) > 0) {
  // yes there was query in last 24 hours
} else {
  // no there wasn't query in last 24 hours
}