【问题标题】:Codeigniter time showing as AM not PMCodeigniter 时间显示为 AM 而不是 PM
【发布时间】:2012-01-03 20:33:01
【问题描述】:

我正在使用 codeigniter 时间助手来回显我的 mysql 数据库的 TIMESTAMP (CURRENT_TIMESTAMP) 行。

我数据库中原始格式的时间戳是:2011-11-15 14:40:45

当我使用助手在我的视图中回显时间时,我得到以下信息:15/11/2011 02:40

我现在的时间似乎在上午。为什么???

这是我用来回显时间的代码:

$the_date = mdate('%d/%m/%Y %h:%i', strtotime($row->date))

echo $the_date

【问题讨论】:

    标签: codeigniter time controller timestamp helper


    【解决方案1】:

    从数据库返回数据时,您需要更改数据的格式。将小写 h (%h) 更改为大写 H (%H) 以返回 24 小时格式,而不是您当前获得的 12 小时格式。

    您的代码应如下所示:

    $the_date = mdate('%d/%m/%Y %H:%i', strtotime($row->date))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-14
      • 1970-01-01
      • 2016-09-15
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      相关资源
      最近更新 更多