【问题标题】:PHP: strtotime()... againPHP:strtotime()...再次
【发布时间】:2009-09-20 20:15:02
【问题描述】:

如何写“+3 days at 12:34:56”才能让 strtotime() 正确解析?

【问题讨论】:

  • 在我的示例中,我希望今天的时间戳为 12:34:56 加上三天。

标签: php string parsing format strtotime


【解决方案1】:
$ts = strtotime("12:34:56 +3 days");
echo date('Y-m-d H:i:s O', $ts);

打印

2009-09-23 12:34:56 +0200

(我的本地时区是 CEST/gmt+2)

【讨论】:

    【解决方案2】:

    哦,我明白了:我只需要删除“at”: “+3 天 12:34:56”解析,耶!

    【讨论】:

      【解决方案3】:

      我个人会做这样的事情:

      date("Y-m-d 12:34:56",time()+(60*60*24*3))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-09-10
        • 2023-03-03
        • 2011-01-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-29
        • 2010-12-03
        相关资源
        最近更新 更多