php compare current date with dates stored in database

后端 未结 5 1329
傲寒
傲寒 2021-01-16 08:32

I am trying coding a php script where i want to extract a date field from a database table,store this date compare it with todays. To see if the data. from database has pass

5条回答
  •  被撕碎了的回忆
    2021-01-16 08:32

    Use strtotime()

    while($info = mysqli_fetch_assoc($result)){
        if(strtotime(date("Y-m-d")) > strtotime($result)){
            exit;
            echo "Success";
        }
        elseif(strtotime(date("Y-m-d")) < strtotime($result)){
            return true;
            echo "Failure";
        }
    }
    

提交回复
热议问题