Take the 2-minute tour ×

Is that normal that this line:

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

gives me 2012-03-18 12:03:00 pm

Whatever the minutes I enter, I always get 03 minutes... weird.

share|improve this question

closed as too localized by casperOne Mar 19 '12 at 16:36


m is the month. –  Simon Mar 18 '12 at 15:55

4 Answers 4

up vote 12 down vote accepted

Your date string format should be :

Y-m-d h:i:s a

PHP's documentation has this to say about formatting a local time/date -

  • i - Minutes with leading zeros
  • m - Numeric representation of a month, with leading zeros

What you were seeing as 03 was actually the month - March :)

share|improve this answer
Haha! Thanks. Programming on week ends, that what's happen :) –  mrmuggles Mar 18 '12 at 16:00
LOL - yep... Occupational hazards ;) –  Lix Mar 18 '12 at 16:01

Your "minutes" are actually "months". Use i as your date code:

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

In PHP's date function, the code for minutes is i not m:

share|improve this answer

That's because m in the date function represents months, not minutes. For minutes, you want to use i:

Y-m-d h:i:s a
share|improve this answer
