【问题标题】:How to return TRUE with time()?如何用 time() 返回 TRUE?
【发布时间】:2023-01-18 03:11:56
【问题描述】:

创建超过 30 天后如何返回 TRUE?

我有以下日期:

$udata['joined']; - 及时记录日期():

我这样试过

`If($udata['joined'] = strtotime ("+30 days", time())){

return true;
}`

知道为什么它不能正常工作吗?

返回空。

【问题讨论】:

    标签: php


    【解决方案1】:

    您正在分配一个值而不是使用 operator,即您使用的是 = 而不是 ==。尝试这个:

    If($udata['joined'] == strtotime ("+30 days", time())){
        return true;
    }
    

    【讨论】:

      【解决方案2】:

      我想你想要

      If timestamp is more than (or exactly) 30 days ago

      if ($udata['joined'] <= strtotime("-30 days", time()) {
          return TRUE;
      }
      

      【讨论】:

        猜你喜欢
        • 2010-10-05
        • 2021-01-26
        • 1970-01-01
        • 2017-05-02
        • 2019-06-10
        • 1970-01-01
        • 2014-02-17
        • 2021-06-20
        • 1970-01-01
        相关资源
        最近更新 更多