【问题标题】:PHP check if data and time more than date and time for this moment [duplicate]PHP检查此时的数据和时间是否超过日期和时间[重复]
【发布时间】:2017-09-27 19:20:54
【问题描述】:

嘿,我想检查现在的时间和日期是否超过时间 例如

if ( date("Y:m:j:H:i:s") >  strtotime("2017:09:27:14:02:05") ) {
 // TODO
}

【问题讨论】:

  • 所以您将时间戳转换为格式化字符串 (date("Y:m:j:H:i:s")) 并将格式化字符串转换为时间戳 (strtotime("2017:09:27:14:02:05")),然后进行比较?!?两者都使用时间戳!提示:time()
  • 将两次都放入DateTime 类,然后对它们执行if >

标签: php time


【解决方案1】:

检查一下:

$date = "2017:09:27:14:02:05";

if ( date("Y:m:j:H:i:s") >  date('Y:m:j:H:i:s', strtotime($date)) ) {

}

祝你好运!

【讨论】:

  • 确实是过度使用函数
  • 谢谢,但不工作,我想要的是为某些东西设置一个到期日期,如果过期会删除它,对不起我的英语不好..
猜你喜欢
  • 2021-07-03
  • 2012-05-27
  • 1970-01-01
  • 1970-01-01
  • 2015-12-23
  • 2011-02-19
  • 1970-01-01
  • 2020-08-14
  • 1970-01-01
相关资源
最近更新 更多