【问题标题】:Time formatting时间格式
【发布时间】:2012-09-21 08:48:43
【问题描述】:

我目前正在正在构建的网站上显示最新的推文,现在还从页面添加最新的 facebook 状态。

从推特接收到的 obj 时间戳格式如下:

Tue Feb 08 11:29:36 +0000 2011

为了保持两者的一致性,我还想格式化 facebook 时间戳以显示相同。

我的问题是,Twitter 时间戳上的 +0000 2011 是什么,因为我正在尝试格式化 fb 时间戳,但没有得到正确的结果(我认为)。

<?php echo date("D M y h:i:s Z", strtotime($status_ob->timestamp)); ?>

返回

Fri Sep 12 09:08:03 7200

这是正确的还是我遗漏了什么。

问候。

菲尔

【问题讨论】:

    标签: php timestamp


    【解决方案1】:

    这应该为您提供您正在寻找的格式。

    <?php echo date("D M d h:i:s O Y", strtotime($status_ob->timestamp)); ?>
    

    O 将为您提供 GMT 偏移量,Y 将为您提供漫长的年份。 我还将您的 y 更改为 d,因为您有一年而不是一天。

    【讨论】:

      【解决方案2】:

      “我的问题是,推特时间戳上的 +0000 2011 是什么”

      我相信 +0000 是时区。

      【讨论】:

      • 实际上,+0000 是时间偏移,因为它没有说明它是哪个时区,只是比较与 GMT/UTC 的时差;)
      【解决方案3】:

      “我的问题是,推特时间戳上的 +0000 2011 是什么”

      What does +0000 mean in the context of a date returned by the twitter API?

      时区

      【讨论】:

        猜你喜欢
        • 2012-01-17
        • 2011-12-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-02-17
        相关资源
        最近更新 更多