Datetime comparison PHP/Mysql?

后端 未结 4 853
醉梦人生
醉梦人生 2021-02-10 05:07

I\'m trying to make something like this:

if (datetime - system date > 15 minutes) (false)

if (datetime - system date          


        
4条回答
  •  [愿得一人]
    2021-02-10 05:43

    the most efficient PHP/MySQL combined solution is:

    $date = date('Y-m-d H:i:s', strtotime('-15 minutes'));
    $data = $pdo->query("SELECT date_field > '$date' as expired from table")->fetchAll(PDO::FETCH_COLUMN);
    foreach($data as $expired) {
        if (!$expired) {
            // Still Valid
        }
    }
    

提交回复
热议问题