2011-11-22 57 views
2

我正在使用codeigniter time helper来回显mysql数据库的TIMESTAMP(CURRENT_TIMESTAMP)行。Codeigniter时间显示为AM不是PM

在我的原始格式数据库的时间戳记是:现在15/11/2011 02:40

我的时间似乎是在AM:2011-11-15 14:40:45

当我使用帮助我得到以下回响在我看来时间。为什么???

这是我使用的回声时间代码:

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

echo $the_date 

回答

2

你需要从数据库中返回时,它改变你的数据的格式。将小写字母h(%h)改为大写字母H(%H),以返回24小时格式,而不是当前正在获取的12小时格式。

你的代码看起来应该像下面的:

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

尼斯之一,三江源 – hairynuggets