【问题标题】:How can i display seconds ago/minutes ago/with unix timestamp?我如何显示几秒钟前/几分钟前/带有unix时间戳?
【发布时间】:2011-02-18 19:29:02
【问题描述】:

我需要 unix 时间戳 - 我拥有的时间戳。然后在twitter上显示like之间的时间。

【问题讨论】:

标签: php unix time


【解决方案1】:

如果有区别就叫diff:

$seconds = intval($diff) % 60;
$minutes = intval($diff/60) % 60;
$hours = intval($diff/3600) % 24;
$days = intval($diff/(3600*24));

这是你想要的吗?

【讨论】:

    【解决方案2】:

    不确定你需要什么语言,但如果它最终会出现在网页中,你可以试试timeago

    【讨论】:

      【解决方案3】:

      使用示例:

      echo time_elapsed_string('@1367367755');
      echo time_elapsed_string('@1367367755', true);
      

      输出:

      4 months ago
      4 months, 2 weeks, 3 days, 1 hour, 49 minutes, 15 seconds ago
      

      Link to the function.

      【讨论】:

        猜你喜欢
        • 2014-09-03
        • 2019-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-29
        相关资源
        最近更新 更多