发现日期是否超过30天 [英] find if date is older than 30 days

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

问题描述

日期字符串看起来像这样

The date string looks like this

2011-08-19 17:14:40

(年 - 月 - 日小时:分:秒)

(year-month-day hours:minutes:seconds)

如何查看日期是否比当前日期超过30天?

How can I find out if the date is older than the current date with more than 30 days?

推荐答案

尝试使用这样的东西:

 if(strtotime('2011-08-19 17:14:40') < strtotime('-30 days')) {
     // this is true
 }

此外,这个字符串看起来像在SQL中存储为datetime /时间戳字段。您可以使用以下方式直接从您的数据库中选择所有条目:

Besides, this string looks like it is stored in SQL as datetime/timestamp field. You can directly select all entries from your database with old dates using:

SELECT ... WHERE `datetime` + INTERVAL 30 DAY < NOW()

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

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