【发布时间】:2012-04-03 07:43:00
【问题描述】:
这行正常吗:
echo date("Y-m-d h:m:s a", strtotime('2012-03-18 12:55:00'))
给我 2012-03-18 12:03:00 pm
无论我输入多少分钟,我总是得到 03 分钟……很奇怪。
【问题讨论】:
这行正常吗:
echo date("Y-m-d h:m:s a", strtotime('2012-03-18 12:55:00'))
给我 2012-03-18 12:03:00 pm
无论我输入多少分钟,我总是得到 03 分钟……很奇怪。
【问题讨论】:
你的日期字符串格式应该是:
Y-m-d h:i:s a
PHP's documentation 有关于格式化本地时间/日期的说法 -
i - 带前导零的分钟m - 月份的数字表示,前导零您所看到的 03 实际上是月份 - 三月 :)
【讨论】:
这是因为日期函数中的m 代表月份,而不是分钟。几分钟,你想使用i:
Y-m-d h:i:s a
【讨论】:
在PHP的date函数中,分钟的代码是i而不是m:
echo date("Y-m-d h:i:s a", strtotime('2012-03-18 12:55:00'))
【讨论】:
您的“分钟”实际上是“月”。使用i 作为您的日期代码:
echo date("Y-m-d h:i:s a", strtotime('2012-03-18 12:55:00'))
【讨论】: