PHP检查日期是否为过去30天 [英] PHP check if date is 30 days in the past

查看:85
本文介绍了PHP检查日期是否为过去30天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有点问题.

我将日期插入数据库: date_last_applied .

I insert a date into the database: date_last_applied.

我当然可以使用 $ row ['date_last_applied'] 来称呼它.现在,我需要检查此插入日期是否是 30天前,如果是,请执行操作.

I can just call this by using $row['date_last_applied'], of course. Now, I need to check if this inserted date was 30 days ago and if so, execute an action.

$query = "SELECT date_last_applied FROM applicants WHERE memberID='$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result)) {
    $date = strtotime($row['date_last_applied']);

}

这就是我所拥有的全部.我尝试了一些尝试,但是都失败了.:(

That's about all I have.. I tried some things, but they all failed. :(

推荐答案

if ($date < strtotime('-30 days'))

如果您在超过30天的日期执行操作,则应使用Marco的解决方案.

If you are only performing actions on dates older than 30 days, you should use Marco's solution.

这篇关于PHP检查日期是否为过去30天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆