如何检查日期是否在今天前三天 [英] how to check if a date is three days before today

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

问题描述

我想知道是否有任何脚本(php)可以检查今天前三天的指定日期。



说..

  $ d1 = date(Ymd ,filemtime($ testfile)); 
$ d2 = date(Y-m-d);

现在我想知道如何比较这两个日期,以检查d1是至少在3ds前在d2
之前,任何帮助将很乐意赞赏。

解决方案

只需检查它与时间戳:

  if(time() -  filemtime($ testfile)> = 3 * 86400){
// ...
}


Hey i would like to know if there is any script (php) that could check if a specified date three days before today.

say..

$d1 = date("Y-m-d", filemtime($testfile));
$d2 = date("Y-m-d");

now i would like to know how to compare this two dates to check if d1 is atleast 3days ago or before d2 any help would be gladly appreciated.

解决方案

Just check it with timestamp:

if (time() - filemtime($testfile) >= 3 * 86400) {
  // ...
}

这篇关于如何检查日期是否在今天前三天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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