检查存储日期是否超过10天

时间:2015-07-05 12:12:44

标签: php mysql pdo

我在MySQL数据库中录制了stored date。如何比较stored date是否超过10天?

存储的日期格式为YYYY-m-d(2015.01.01)

$today = date('Y-m-d');
foreach ($result as $val){
  $dbDate = $val["storedDate"];
}

1 个答案:

答案 0 :(得分:3)

$today = date('Y-m-d');
foreach ($result as $val){
    if((time() - strtotime($val["storedDate"])) > (60 * 60 * 24 * 10)){
        //do something
    }
}