2012-03-18 78 views
1

这是正常的,这行:PHP的strtotime问题分钟

echo date("Y-m-d h:m:s a", strtotime('2012-03-18 12:55:00')) 

给我2012-03-18下午12点03分00秒

不管我进入分钟,我总是得到03分钟... 奇怪的。

+3

m是月份。 – Simon 2012-03-18 15:55:03

回答

14

您的日期字符串格式应该是:

Y-m-d h:i:s a

PHP's documentation具有这样说格式化本地时间/日期 -

  • i - 分钟零
  • m - 一个月的数字表示,带前导零

是你所看到的03竟是个月 - 三月:)

+1

哈哈!谢谢。周末编程,发生了什么:) – mrmuggles 2012-03-18 16:00:31

+1

LOL - yep ...职业危害;) – Lix 2012-03-18 16:01:37

1

这是因为m在日期函数表示个月,而不是几分钟。对于分钟,你想用i

Y-m-d h:i:s a 
1

在PHP的date功能,几分钟代码i没有m

echo date("Y-m-d h:i:s a", strtotime('2012-03-18 12:55:00')) 
1

你的 “分钟” 实际上是 “几个月”。使用i作为日期代码:

echo date("Y-m-d h:i:s a", strtotime('2012-03-18 12:55:00'))