【问题标题】:Shorten date notation codeigniter缩短日期符号codeigniter
【发布时间】:2015-05-02 12:51:52
【问题描述】:

我正在使用 CodeIgniter 构建一个 webapp,我想展示最新的帖子。我计算发布日期和当前日期之间的时间。问题是它显示如下:1d 4h 2m 或 9h 32m。所以我实际上只想在这种情况下显示 1d 或 9h。这怎么可能?

这是我计算时间的方式:

span class="time"><?php
                           $this->load->helper('date');

                           $post_date = strtotime($t['story_date']);
                           $now = strtotime(date('Y-m-d H:i:s'));

                           echo timespan($post_date, $now);

                           ?> </span>

【问题讨论】:

    标签: php codeigniter date time


    【解决方案1】:

    时间跨度函数有一个名为“单位”的第三个参数 - 也许这有帮助吗? 更多信息请关注here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      • 2019-12-13
      相关资源
      最近更新 更多