MySQL查询基于日期

时间:2013-02-21 20:22:10

标签: php mysqli

我需要一个sql语句的帮助。我有一个基于'喜欢'的特色用户系统,但是一旦用户被'推荐',他们就不能在接下来的30天内出现。这已完全用php / mysql编写。任何想法?

1 个答案:

答案 0 :(得分:1)

php端的伪代码:

     $new_date = new DateTime;         
     $new_date->modify('30 day'); //set the next time they can be featured to 30 days in the future   

     while ($row = $qryResult ->fetch_assoc()) { //query table containing user, featured yes/no, date, etc
        $featured_date = new DateTime($row['featuredDate']);

     if ($featured date < $new_date) {
         echo $row['user'];
    }
  }