tags:

views:

48

answers:

5

I am getting the date from my MySQL database and that date is correct, but when I use the date() function the minute part is stuck at 6 minutes.

MySQL is returning 2010-06-15 09:59:18

Then in PHP I use this code ($row[4] is from my while loop):

date('M d,Y H:m A',strtotime($row[4]))

When I echo this out I get: Jun 15,2010 9:06 AM

I also have tried converting it to a unix timestamp in my SQL query, but it does the same thing. I noticed that the hours work and the seconds work but the minutes are stuck at 6. Does anyone have any ideas on what is going on?

+8  A: 

'm' is a representation of month, not minutes using the PHP date() function. So, you are getting the '06', meaning June, not 06 minutes past 9.

It only looks like minutes because of how you formatted your date string but what you are getting there is a numerical representation of the month.

Evernoob
Thanks, I must have been suffering from an brain fart.
WAC0020
Lol, no worries!
Evernoob
+4  A: 

http://us2.php.net/manual/en/function.date.php

m - Numeric representation of a month, with leading zeros

a1ex07
...and `i` will give minutes with leading zeros.
FrustratedWithFormsDesigner
A: 

I think the minute arg should be i (lowercase eye), not m.

MJB
A: 

Use this instead (i instead of m):

date('M d,Y H:i A',strtotime($row[4]))
JYelton
A: 

The capital m is the month, and now it's June ;) The minute is "i"

Tobias P.